From 9a920248d3e107fd2e2e934eb59eb3de8edef59a Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Sat, 14 Mar 2020 21:10:23 +0100 Subject: [PATCH] [wofi] try makeing system.sh more beautiful --- wofi/system.sh | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/wofi/system.sh b/wofi/system.sh index 9bb9e2b..91ff76c 100755 --- a/wofi/system.sh +++ b/wofi/system.sh @@ -1,20 +1,21 @@ #!/bin/bash -chosen=$(echo -e "[Cancel]\nLogout\nShutdown\nReboot\nSuspend\nHibernate\nHybrid-sleep\nSuspend-then-hibernate" | wofi --dmenu --insensitive) +chosen="$(wofi --dmenu --insensitive <<-END +[Cancel] +Logout +Shutdown +Reboot +Suspend +Hibernate +Suspend-then-hibernate +END +)" -if [[ $chosen = "Logout" ]]; then +if [[ "${chosen}" = "Logout" ]]; then swaymsg exit loginctl terminate-session "$(loginctl session-status | awk 'NR==1{print $1}')" -elif [[ $chosen = "Shutdown" ]]; then - systemctl poweroff -elif [[ $chosen = "Reboot" ]]; then - systemctl reboot -elif [[ $chosen = "Suspend" ]]; then - systemctl suspend -elif [[ $chosen = "Hibernate" ]]; then - systemctl hibernate -elif [[ $chosen = "Hybrid-sleep" ]]; then - systemctl hibernate -elif [[ $chosen = "Suspend-then-hibernate" ]]; then - systemctl suspend-then-hibernate +elif [ -z "${chosen}" ] || [[ "${chosen}" = "[Cancel]" ]]; then + exit 0; fi + +systemctl "$(tr '[:upper:]' '[:lower:]' <<< "${chosen}")"