summaryrefslogtreecommitdiff
path: root/tw/home/files
diff options
context:
space:
mode:
authorTimo Wilken2023-06-30 21:48:38 +0200
committerTimo Wilken2023-06-30 21:48:38 +0200
commitbdb21b510e38dbd7b80aa032a7a1fde73fdb3dc4 (patch)
tree9b57e638e25d190be240a28a87a4869d75e52b34 /tw/home/files
parent80c92e8ecd4d89c3eb4cb99f71af704efff4c175 (diff)
Add WIP sleep support to sessionmenu
Doesn't really work yet, because writing to /sys/power/state needs root.
Diffstat (limited to 'tw/home/files')
-rwxr-xr-xtw/home/files/sessionmenu9
1 files changed, 9 insertions, 0 deletions
diff --git a/tw/home/files/sessionmenu b/tw/home/files/sessionmenu
index 552c2b3c..91839d8e 100755
--- a/tw/home/files/sessionmenu
+++ b/tw/home/files/sessionmenu
@@ -14,6 +14,14 @@
(exit 0))
((_ "Reload i3 configuration")
(call-command/stderr "i3-msg" "reload"))
+ ((_ "Sleep")
+ ;; "screenlock" blocks until unlocked by the user, so run in background.
+ ;; TODO: write "mem" to /sys/power/state, but it's owned by root.
+ (let ((locker (spawn "screenlock" '("screenlock")))
+ (sleepfile (open-file "/sys/power/state" "w")))
+ (display "mem" sleepfile)
+ (close sleepfile)
+ (waitpid locker)))
((_ "Log out")
(call-command/stderr "i3-msg" "exit"))
((_ "Shutdown")
@@ -24,6 +32,7 @@
(format #t "\0~a\x1f~a~%~{~a\0icon\x1f~a~%~}"
"prompt" "Session"
'("Reload i3 configuration" "reload"
+ "Sleep" "system-suspend"
"Log out" "system-log-out"
"Shutdown" "system-shutdown"
"Reboot" "system-reboot"))))