aboutsummaryrefslogtreecommitdiff
path: root/tw/home/files/sessionmenu
diff options
context:
space:
mode:
Diffstat (limited to 'tw/home/files/sessionmenu')
-rwxr-xr-xtw/home/files/sessionmenu29
1 files changed, 29 insertions, 0 deletions
diff --git a/tw/home/files/sessionmenu b/tw/home/files/sessionmenu
new file mode 100755
index 00000000..552c2b3c
--- /dev/null
+++ b/tw/home/files/sessionmenu
@@ -0,0 +1,29 @@
+#!/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"))
+ ((_ "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"
+ "Log out" "system-log-out"
+ "Shutdown" "system-shutdown"
+ "Reboot" "system-reboot"))))