summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-09-23 14:38:44 +1000
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-09-23 14:38:44 +1000
commit95fc1c7fba297044dd2d8f3399c72864d7d2c908 (patch)
tree5e7699ccb0cc731465d7fcfe237d9c9308d5e405
parentinternal: add toasts for gamemode & dnd (diff)
downloadcaelestia-shell-95fc1c7fba297044dd2d8f3399c72864d7d2c908.tar.gz
caelestia-shell-95fc1c7fba297044dd2d8f3399c72864d7d2c908.tar.bz2
caelestia-shell-95fc1c7fba297044dd2d8f3399c72864d7d2c908.zip
idlemonitor: configurable timeouts
Closes #669
-rw-r--r--README.md18
-rw-r--r--config/GeneralConfig.qml18
-rw-r--r--modules/IdleMonitors.qml46
3 files changed, 53 insertions, 29 deletions
diff --git a/README.md b/README.md
index 421b012..71aedbf 100644
--- a/README.md
+++ b/README.md
@@ -279,9 +279,21 @@ default, you must create it manually.
},
"idle": {
"inhibitWhenAudio": true,
- "lockTimeout": 180,
- "dpmsTimeout": 300,
- "sleepTimeout": 600
+ "timeouts": [
+ {
+ "timeout": 180,
+ "idleAction": "lock"
+ },
+ {
+ "timeout": 300,
+ "idleAction": "dpms off",
+ "returnAction": "dpms on"
+ },
+ {
+ "timeout": 600,
+ "idleAction": ["systemctl", "suspend-then-hibernate"]
+ }
+ ]
}
},
"background": {
diff --git a/config/GeneralConfig.qml b/config/GeneralConfig.qml
index 4d7a79c..d53364b 100644
--- a/config/GeneralConfig.qml
+++ b/config/GeneralConfig.qml
@@ -14,9 +14,21 @@ JsonObject {
component Idle: JsonObject {
property bool inhibitWhenAudio: true
- property real lockTimeout: 180 // 3 mins
- property real dpmsTimeout: 300 // 5 mins
- property real sleepTimeout: 600 // 10 mins
+ property list<var> timeouts: [
+ {
+ timeout: 180,
+ idleAction: "lock"
+ },
+ {
+ timeout: 300,
+ idleAction: "dpms off",
+ returnAction: "dpms on"
+ },
+ {
+ timeout: 600,
+ idleAction: ["systemctl", "suspend-then-hibernate"]
+ }
+ ]
}
component Battery: JsonObject {
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)
}
}
}