aboutsummaryrefslogtreecommitdiff
path: root/tw/services/files/sessionmenu
diff options
context:
space:
mode:
authorTimo Wilken2024-07-11 17:11:25 +0200
committerTimo Wilken2024-07-11 17:11:25 +0200
commite6f26581bf22e266c5056eddfb264eca2efb6ef4 (patch)
tree08c436f4b5d4fe66bbf9b6a67bb1020568737e93 /tw/services/files/sessionmenu
parentc2c6421d3f8db9920fe50f07eff226641586f87a (diff)
Wayland-based desktop support
Add a separate home service to configure a Wayland-based desktop instead of an X11 one. Screensharing in Zoom doesn't work unfortunately, but it worked (at least for a while) through OBS. Waybar might need some work to bring it in line with the previous polybar configuration, especially in terms of aesthetics.
Diffstat (limited to 'tw/services/files/sessionmenu')
-rwxr-xr-xtw/services/files/sessionmenu34
1 files changed, 22 insertions, 12 deletions
diff --git a/tw/services/files/sessionmenu b/tw/services/files/sessionmenu
index 91839d8e..4f145d34 100755
--- a/tw/services/files/sessionmenu
+++ b/tw/services/files/sessionmenu
@@ -4,26 +4,34 @@
(ice-9 match)
(ice-9 ports))
+(define wm
+ (cond ((getenv "SWAYSOCK") 'sway)
+ ((getenv "I3SOCK") 'i3)
+ (else #f)))
+
(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))))
+(define (wm-msg . command)
+ (apply call-command/stderr
+ (match wm
+ (sway "swaymsg")
+ (i3 "i3-msg")
+ (_ (error "No recognised window manager running")))
+ command))
+
(match (command-line)
((_ "quit")
(exit 0))
- ((_ "Reload i3 configuration")
- (call-command/stderr "i3-msg" "reload"))
+ ((_ "Reload WM configuration")
+ (wm-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)))
+ ;; Rely on swayidle to lock the screen before going to sleep.
+ (call-command/stderr "loginctl" "suspend"))
((_ "Log out")
- (call-command/stderr "i3-msg" "exit"))
+ (wm-msg "exit"))
((_ "Shutdown")
(call-command/stderr "sudo" "-n" "/run/current-system/profile/sbin/shutdown"))
((_ "Reboot")
@@ -31,8 +39,10 @@
(_
(format #t "\0~a\x1f~a~%~{~a\0icon\x1f~a~%~}"
"prompt" "Session"
- '("Reload i3 configuration" "reload"
+ `(,@(if wm
+ '("Reload WM configuration" "reload"
+ "Log out" "system-log-out")
+ '())
"Sleep" "system-suspend"
- "Log out" "system-log-out"
"Shutdown" "system-shutdown"
"Reboot" "system-reboot"))))