debug: add --display arg

This commit is contained in:
Vaxry 2024-02-19 15:20:52 +00:00
parent 5e4eea379e
commit dfd2f851da
3 changed files with 11 additions and 6 deletions

View file

@ -7,8 +7,8 @@
#include <sys/mman.h> #include <sys/mman.h>
#include <cuchar> #include <cuchar>
CHyprlock::CHyprlock() { CHyprlock::CHyprlock(const std::string& wlDisplay) {
m_sWaylandState.display = wl_display_connect(nullptr); m_sWaylandState.display = wl_display_connect(wlDisplay.empty() ? nullptr : wlDisplay.c_str());
if (!m_sWaylandState.display) { if (!m_sWaylandState.display) {
Debug::log(CRIT, "Couldn't connect to a wayland compositor"); Debug::log(CRIT, "Couldn't connect to a wayland compositor");
exit(1); exit(1);

View file

@ -14,7 +14,7 @@
class CHyprlock { class CHyprlock {
public: public:
CHyprlock(); CHyprlock(const std::string& wlDisplay);
void run(); void run();

View file

@ -2,7 +2,9 @@
#include "config/ConfigManager.hpp" #include "config/ConfigManager.hpp"
#include "core/hyprlock.hpp" #include "core/hyprlock.hpp"
int main(int argc, char **argv, char **envp) { int main(int argc, char** argv, char** envp) {
std::string wlDisplay;
for (int i = 1; i < argc; ++i) { for (int i = 1; i < argc; ++i) {
std::string arg = argv[i]; std::string arg = argv[i];
@ -11,12 +13,15 @@ int main(int argc, char **argv, char **envp) {
else if (arg == "--quiet" || arg == "-q") else if (arg == "--quiet" || arg == "-q")
Debug::quiet = true; Debug::quiet = true;
else if (arg == "--display" && i + 1 < argc)
wlDisplay = argv[i + 1];
} }
try { try {
g_pConfigManager = std::make_unique<CConfigManager>(); g_pConfigManager = std::make_unique<CConfigManager>();
g_pConfigManager->init(); g_pConfigManager->init();
} catch (const char *err) { } catch (const char* err) {
Debug::log(CRIT, "ConfigManager threw: {}", err); Debug::log(CRIT, "ConfigManager threw: {}", err);
std::string strerr = err; std::string strerr = err;
if (strerr.contains("File does not exist")) if (strerr.contains("File does not exist"))
@ -24,7 +29,7 @@ int main(int argc, char **argv, char **envp) {
return 1; return 1;
} }
g_pHyprlock = std::make_unique<CHyprlock>(); g_pHyprlock = std::make_unique<CHyprlock>(wlDisplay);
g_pHyprlock->run(); g_pHyprlock->run();
return 0; return 0;