summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/IdleMonitors.qml46
1 files changed, 23 insertions, 23 deletions
diff --git a/modules/IdleMonitors.qml b/modules/IdleMonitors.qml
index 3150973..3e98bc5 100644
--- a/modules/IdleMonitors.qml
+++ b/modules/IdleMonitors.qml
@@ -1,3 +1,5 @@
+pragma ComponentBehavior: Bound
+
import "lock"
import qs.config
import qs.services
@@ -10,32 +12,30 @@ Scope {
required property Lock lock
readonly property bool enabled: !Config.general.idle.inhibitWhenAudio || !Players.list.some(p => p.isPlaying)
- IdleMonitor {
- enabled: root.enabled
- timeout: Config.general.idle.lockTimeout
- onIsIdleChanged: {
- if (isIdle)
- root.lock.lock.locked = true;
- }
- }
+ function handleIdleAction(action: var): void {
+ if (!action)
+ return;
- IdleMonitor {
- enabled: root.enabled
- timeout: Config.general.idle.dpmsTimeout
- onIsIdleChanged: {
- if (isIdle)
- Hypr.dispatch("dpms off");
- else
- Hypr.dispatch("dpms on");
- }
+ if (action === "lock")
+ root.lock.lock.locked = true;
+ else if (action === "unlock")
+ root.lock.lock.locked = false;
+ else if (typeof action === "string")
+ Hypr.dispatch(action);
+ else
+ Quickshell.execDetached(action);
}
- IdleMonitor {
- enabled: root.enabled
- timeout: Config.general.idle.sleepTimeout
- onIsIdleChanged: {
- if (isIdle)
- Quickshell.execDetached(["systemctl", "suspend-then-hibernate"]);
+ Variants {
+ model: Config.general.idle.timeouts
+
+ IdleMonitor {
+ required property var modelData
+
+ enabled: root.enabled && (modelData.enabled ?? true)
+ timeout: modelData.timeout
+ respectInhibitors: modelData.respectInhibitors ?? true
+ onIsIdleChanged: root.handleIdleAction(isIdle ? modelData.idleAction : modelData.returnAction)
}
}
}