diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index f34e5b8..1a8d988 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -80,6 +80,10 @@ std::vector CConfigManager::getRules() { return m_vRules; } +std::string CConfigManager::getOnTimeoutCommand() { + return m_vRules.front().onTimeout; +} + void* const* CConfigManager::getValuePtr(const std::string& name) { return m_config.getConfigValuePtr(name.c_str())->getDataStaticPtr(); } diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp index 6f7c402..6b82960 100644 --- a/src/config/ConfigManager.hpp +++ b/src/config/ConfigManager.hpp @@ -18,6 +18,7 @@ class CConfigManager { std::string onResume = ""; }; + std::string getOnTimeoutCommand(); std::vector getRules(); void* const* getValuePtr(const std::string& name); diff --git a/src/core/Hypridle.cpp b/src/core/Hypridle.cpp index 38b5d04..c38fcb5 100644 --- a/src/core/Hypridle.cpp +++ b/src/core/Hypridle.cpp @@ -261,7 +261,7 @@ static void spawn(const std::string& args) { void CHypridle::onIdled(SIdleListener* pListener) { Debug::log(LOG, "Idled: rule {:x}", (uintptr_t)pListener); - + isIdled = true; if (g_pHypridle->m_iInhibitLocks > 0) { Debug::log(LOG, "Ignoring from onIdled(), inhibit locks: {}", g_pHypridle->m_iInhibitLocks); return; @@ -278,7 +278,7 @@ void CHypridle::onIdled(SIdleListener* pListener) { void CHypridle::onResumed(SIdleListener* pListener) { Debug::log(LOG, "Resumed: rule {:x}", (uintptr_t)pListener); - + isIdled = false; if (g_pHypridle->m_iInhibitLocks > 0) { Debug::log(LOG, "Ignoring from onResumed(), inhibit locks: {}", g_pHypridle->m_iInhibitLocks); return; @@ -301,8 +301,15 @@ void CHypridle::onInhibit(bool lock) { // you have been warned. m_iInhibitLocks = 0; Debug::log(WARN, "BUG THIS: inhibit locks < 0. Brought back to 0."); - } else + } else if (m_iInhibitLocks > 0) { Debug::log(LOG, "Inhibit locks: {}", m_iInhibitLocks); + } else { + Debug::log(LOG, "Inhibit locks: {}", m_iInhibitLocks); + if (isIdled && lock) { + Debug::log(LOG, "Running from onInhibit() isIdled = true {}", g_pConfigManager->getOnTimeoutCommand()); + spawn(g_pConfigManager->getOnTimeoutCommand()); + } + } } CHypridle::SDbusInhibitCookie CHypridle::getDbusInhibitCookie(uint32_t cookie) { diff --git a/src/core/Hypridle.hpp b/src/core/Hypridle.hpp index f5352e9..f8fbdea 100644 --- a/src/core/Hypridle.hpp +++ b/src/core/Hypridle.hpp @@ -42,6 +42,7 @@ class CHypridle { void enterEventLoop(); bool m_bTerminate = false; + bool isIdled = false; int64_t m_iInhibitLocks = 0; struct {