From a3e0cc80fdcb6eff8febf9809e601e4fe459b90e Mon Sep 17 00:00:00 2001 From: Timo Wilken Date: Sun, 11 Dec 2022 14:31:33 +0100 Subject: Redirect sessionmenu output properly --- sessionmenu | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/sessionmenu b/sessionmenu index be14e6e1..552c2b3c 100755 --- a/sessionmenu +++ b/sessionmenu @@ -1,19 +1,25 @@ #!/usr/bin/env -S guile --no-auto-compile !# (use-modules (ice-9 format) - (ice-9 match)) + (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") - (system* "i3-msg" "reload")) + (call-command/stderr "i3-msg" "reload")) ((_ "Log out") - (system* "i3-msg" "exit")) + (call-command/stderr "i3-msg" "exit")) ((_ "Shutdown") - (system* "sudo" "-n" "/run/current-system/profile/sbin/shutdown")) + (call-command/stderr "sudo" "-n" "/run/current-system/profile/sbin/shutdown")) ((_ "Reboot") - (system* "sudo" "-n" "/run/current-system/profile/sbin/reboot")) + (call-command/stderr "sudo" "-n" "/run/current-system/profile/sbin/reboot")) (_ (format #t "\0~a\x1f~a~%~{~a\0icon\x1f~a~%~}" "prompt" "Session" -- cgit v1.2.3