diff options
| author | MithicSpirit <rpc01234@gmail.com> | 2025-10-19 07:54:27 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-19 13:54:27 +0200 |
| commit | 59ff7b2f891d06f4097128faf7027a3863542167 (patch) | |
| tree | 9fe373158653b7588ee0efa036059c3bb21f592c /src/managers/KeybindManager.cpp | |
| parent | ba077d8ff09e38a5b20c5d06d71daab52bbcc36d (diff) | |
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.
Diffstat (limited to 'src/managers/KeybindManager.cpp')
| -rw-r--r-- | src/managers/KeybindManager.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
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<float> 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=<NEW_MODKEYS><NEW_KEY><STATE>[,WINDOW_RULES] const auto ARGS = CVarList(args, 4); |
