summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md5
-rw-r--r--config/GeneralConfig.qml7
-rw-r--r--modules/IdleMonitors.qml37
-rw-r--r--modules/lock/Lock.qml1
-rw-r--r--shell.qml7
5 files changed, 56 insertions, 1 deletions
diff --git a/README.md b/README.md
index 05ee139..f9e001c 100644
--- a/README.md
+++ b/README.md
@@ -252,6 +252,11 @@ default, you must create it manually.
"apps": {
"terminal": ["foot"],
"audio": ["pavucontrol"]
+ },
+ "idle": {
+ "lockTimeout": 180,
+ "dpmsTimeout": 300,
+ "sleepTimeout": 600
}
},
"background": {
diff --git a/config/GeneralConfig.qml b/config/GeneralConfig.qml
index b9fa364..91c85fc 100644
--- a/config/GeneralConfig.qml
+++ b/config/GeneralConfig.qml
@@ -2,6 +2,7 @@ import Quickshell.Io
JsonObject {
property Apps apps: Apps {}
+ property Idle idle: Idle {}
component Apps: JsonObject {
property list<string> terminal: ["foot"]
@@ -9,4 +10,10 @@ JsonObject {
property list<string> playback: ["mpv"]
property list<string> explorer: ["thunar"]
}
+
+ component Idle: JsonObject {
+ property real lockTimeout: 180 // 3 mins
+ property real dpmsTimeout: 300 // 5 mins
+ property real sleepTimeout: 600 // 10 mins
+ }
}
diff --git a/modules/IdleMonitors.qml b/modules/IdleMonitors.qml
new file mode 100644
index 0000000..ed929c4
--- /dev/null
+++ b/modules/IdleMonitors.qml
@@ -0,0 +1,37 @@
+import "lock"
+import qs.config
+import qs.services
+import Quickshell
+import Quickshell.Wayland
+
+Scope {
+ id: root
+
+ required property Lock lock
+
+ IdleMonitor {
+ timeout: Config.general.idle.lockTimeout
+ onIsIdleChanged: {
+ if (isIdle)
+ root.lock.lock.locked = true;
+ }
+ }
+
+ IdleMonitor {
+ timeout: Config.general.idle.dpmsTimeout
+ onIsIdleChanged: {
+ if (isIdle)
+ Hypr.dispatch("dpms off");
+ else
+ Hypr.dispatch("dpms on");
+ }
+ }
+
+ IdleMonitor {
+ timeout: Config.general.idle.sleepTimeout
+ onIsIdleChanged: {
+ if (isIdle)
+ Quickshell.execDetached(["systemctl", "suspend-then-hibernate"]);
+ }
+ }
+}
diff --git a/modules/lock/Lock.qml b/modules/lock/Lock.qml
index fc0bff8..6fd5277 100644
--- a/modules/lock/Lock.qml
+++ b/modules/lock/Lock.qml
@@ -6,6 +6,7 @@ import Quickshell.Io
import Quickshell.Wayland
Scope {
+ property alias lock: lock
WlSessionLock {
id: lock
diff --git a/shell.qml b/shell.qml
index 8a83573..a56caae 100644
--- a/shell.qml
+++ b/shell.qml
@@ -13,7 +13,12 @@ ShellRoot {
Background {}
Drawers {}
AreaPicker {}
- Lock {}
+ Lock {
+ id: lock
+ }
Shortcuts {}
+ IdleMonitors {
+ lock: lock
+ }
}