From 8bfa54e30d16b603a817d288587b10c6037a53e7 Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Sat, 13 Jan 2024 01:14:19 -0500 Subject: [PATCH] Add wrapper script for exiting session --- dot_config/wleave/layout | 6 +++--- dot_local/bin/executable_river-exit | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 dot_local/bin/executable_river-exit diff --git a/dot_config/wleave/layout b/dot_config/wleave/layout index 61fa2fd..16a0169 100644 --- a/dot_config/wleave/layout +++ b/dot_config/wleave/layout @@ -12,13 +12,13 @@ } { "label" : "logout", - "action" : "${HOME}/.local/bin/river-logout", + "action" : "${HOME}/.local/bin/river-exit logout", "text" : "Logout", "keybind" : "e" } { "label" : "shutdown", - "action" : "loginctl poweroff", + "action" : "${HOME}/.local/bin/river-exit poweroff", "text" : "Shutdown", "keybind" : "s" } @@ -30,7 +30,7 @@ } { "label" : "reboot", - "action" : "loginctl reboot", + "action" : "${HOME}/.local/bin/river-exit reboot", "text" : "Reboot", "keybind" : "r" } diff --git a/dot_local/bin/executable_river-exit b/dot_local/bin/executable_river-exit new file mode 100644 index 0000000..c2137bb --- /dev/null +++ b/dot_local/bin/executable_river-exit @@ -0,0 +1,26 @@ +#!/bin/sh + +river=$(ps -C river | awk '/river/') + +if [ -z "$river" ]; then + echo "error: $0: River is not running" + exit 1 +elif [ $# -ne 1 ]; then + echo "Usage: river-exit [command]" + echo "Commands: logout, poweroff, or reboot" + exit 1 +fi + +if [ "$1" = "logout" ]; then + riverctl spawn 'reset' + riverctl exit +elif [ "$1" = "poweroff" ]; then + riverctl spawn 'reset' + loginctl poweroff +elif [ "$1" = "reboot" ]; then + riverctl spawn 'reset' + loginctl reboot +else + echo "error: $0: unexpected argument" + exit 1 +fi