From 59ff7b2f891d06f4097128faf7027a3863542167 Mon Sep 17 00:00:00 2001 From: MithicSpirit Date: Sun, 19 Oct 2025 07:54:27 -0400 Subject: dispatchers: add forceidle (#11922) The forceidle dispatcher resets all ext-idle-notify timers as if the user had been idle for the specified number of seconds. If a notification has already fired, but would now be set with a nonzero delay, then it is reset. Conversely, if a timer has not yet fired, but would now be set to a nonpositive delay, then it is immediately fired. This process ignores any existing inhibitors, but timers are otherwise reset as normal if any new inhibitors are created or destroyed. --- src/managers/KeybindManager.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/managers/KeybindManager.cpp') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index c9008c2f..d04d6ba7 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -4,6 +4,7 @@ #include "../protocols/LayerShell.hpp" #include "../protocols/ShortcutsInhibit.hpp" #include "../protocols/GlobalShortcuts.hpp" +#include "../protocols/IdleNotify.hpp" #include "../protocols/core/DataDevice.hpp" #include "../render/decorations/CHyprGroupBarDecoration.hpp" #include "KeybindManager.hpp" @@ -143,6 +144,7 @@ CKeybindManager::CKeybindManager() { m_dispatchers["event"] = event; m_dispatchers["global"] = global; m_dispatchers["setprop"] = setProp; + m_dispatchers["forceidle"] = forceIdle; m_scrollTimer.reset(); @@ -3257,6 +3259,19 @@ SDispatchResult CKeybindManager::setProp(std::string args) { return {}; } +SDispatchResult CKeybindManager::forceIdle(std::string args) { + std::optional duration = getPlusMinusKeywordResult(args, 0); + + if (!duration.has_value()) { + Debug::log(ERR, "Duration invalid in forceIdle!"); + return {.success = false, .error = "Duration invalid in forceIdle!"}; + } + + PROTO::idle->setTimers(duration.value() * 1000.0); + + return {}; +} + SDispatchResult CKeybindManager::sendkeystate(std::string args) { // args=[,WINDOW_RULES] const auto ARGS = CVarList(args, 4); -- cgit v1.2.3