diff options
author | Timo Wilken | 2024-03-09 14:52:56 +0100 |
---|---|---|
committer | Timo Wilken | 2024-03-10 16:19:00 +0100 |
commit | de20fc8d904643ffe6957febfc6a24e57c12b512 (patch) | |
tree | 8177459e40786bd432a37c5833f26350fb689356 /tw/services/files/sessionmenu | |
parent | da5e9d5ee98dfc216eb7e3b1559c09f4bf868bf6 (diff) |
Separate home service into PIM, dev env and graphical parts
This means we only instantiate Shepherd and mcron services if we really need
them, to avoid annoyance on servers.
Diffstat (limited to 'tw/services/files/sessionmenu')
-rwxr-xr-x | tw/services/files/sessionmenu | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tw/services/files/sessionmenu b/tw/services/files/sessionmenu new file mode 100755 index 00000000..91839d8e --- /dev/null +++ b/tw/services/files/sessionmenu @@ -0,0 +1,38 @@ +#!/usr/bin/env -S guile --no-auto-compile +!# +(use-modules (ice-9 format) + (ice-9 match) + (ice-9 ports)) + +(define (call-command/stderr . command) + "Call COMMAND using `system*', but redirect all output to stderr." + (with-output-to-port (current-error-port) + (lambda () (apply system* command)))) + +(match (command-line) + ((_ "quit") + (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") + (call-command/stderr "sudo" "-n" "/run/current-system/profile/sbin/shutdown")) + ((_ "Reboot") + (call-command/stderr "sudo" "-n" "/run/current-system/profile/sbin/reboot")) + (_ + (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")))) |