diff --git a/src/core/hyprlock.cpp b/src/core/hyprlock.cpp index a99727a..f605373 100644 --- a/src/core/hyprlock.cpp +++ b/src/core/hyprlock.cpp @@ -7,8 +7,8 @@ #include #include -CHyprlock::CHyprlock() { - m_sWaylandState.display = wl_display_connect(nullptr); +CHyprlock::CHyprlock(const std::string& wlDisplay) { + m_sWaylandState.display = wl_display_connect(wlDisplay.empty() ? nullptr : wlDisplay.c_str()); if (!m_sWaylandState.display) { Debug::log(CRIT, "Couldn't connect to a wayland compositor"); exit(1); diff --git a/src/core/hyprlock.hpp b/src/core/hyprlock.hpp index 7e82e18..9b305af 100644 --- a/src/core/hyprlock.hpp +++ b/src/core/hyprlock.hpp @@ -14,7 +14,7 @@ class CHyprlock { public: - CHyprlock(); + CHyprlock(const std::string& wlDisplay); void run(); diff --git a/src/main.cpp b/src/main.cpp index def4a43..b3a1f55 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,7 +2,9 @@ #include "config/ConfigManager.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) { std::string arg = argv[i]; @@ -11,12 +13,15 @@ int main(int argc, char **argv, char **envp) { else if (arg == "--quiet" || arg == "-q") Debug::quiet = true; + + else if (arg == "--display" && i + 1 < argc) + wlDisplay = argv[i + 1]; } try { g_pConfigManager = std::make_unique(); g_pConfigManager->init(); - } catch (const char *err) { + } catch (const char* err) { Debug::log(CRIT, "ConfigManager threw: {}", err); std::string strerr = err; if (strerr.contains("File does not exist")) @@ -24,7 +29,7 @@ int main(int argc, char **argv, char **envp) { return 1; } - g_pHyprlock = std::make_unique(); + g_pHyprlock = std::make_unique(wlDisplay); g_pHyprlock->run(); return 0;