diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 97dae134..6d37c97b 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -263,7 +263,7 @@ void CConfigManager::parseLine(std::string& line) { return; } else if (COMMAND == "exec-once") { if (isFirstLaunch) { - handleRawExec(COMMAND, VALUE); + firstExecRequests.push_back(VALUE); } return; } else if (COMMAND == "monitor") { @@ -478,4 +478,17 @@ std::vector CConfigManager::getMatchingRules(CWindow* pWindow) { } return returns; +} + +void CConfigManager::dispatchExecOnce() { + if (firstExecDispatched || isFirstLaunch) + return; + + firstExecDispatched = true; + + for (auto& c : firstExecRequests) { + handleRawExec("", c); + } + + firstExecRequests.clear(); // free some kb of memory :P } \ No newline at end of file diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp index 663480d4..45946b93 100644 --- a/src/config/ConfigManager.hpp +++ b/src/config/ConfigManager.hpp @@ -51,6 +51,9 @@ public: std::vector getMatchingRules(CWindow*); + // no-op when done. + void dispatchExecOnce(); + private: std::unordered_map configValues; time_t lastModifyTime = 0; // for reloading the config if changed @@ -64,6 +67,9 @@ private: std::deque m_dMonitorRules; std::deque m_dWindowRules; + bool firstExecDispatched = false; + std::deque firstExecRequests; + // internal methods void loadConfigLoadVars(); SConfigValue getConfigValueSafe(std::string); diff --git a/src/events/Monitors.cpp b/src/events/Monitors.cpp index ab8c2cb7..ef9518fc 100644 --- a/src/events/Monitors.cpp +++ b/src/events/Monitors.cpp @@ -118,6 +118,8 @@ void Events::listener_monitorFrame(void* owner, void* data) { g_pCompositor->sanityCheckWorkspaces(); g_pAnimationManager->tick(); g_pCompositor->cleanupWindows(); + + g_pConfigManager->dispatchExecOnce(); // We exec-once when at least one monitor starts refreshing, meaning stuff has init'd } timespec now;