diff options
| author | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2022-05-15 12:02:59 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2022-05-15 12:02:59 +0200 |
| commit | 115ff9a06870d51702918cd926199e2271bf4f92 (patch) | |
| tree | 4c2abf616b9eec3ba485f49bcefaf0a98882fa33 /dmenu-dwm-sessionmanager | |
| parent | 5ca3ebbf7c3cef6db6b8270af4fcf0be087c29c1 (diff) | |
| download | scripts-115ff9a06870d51702918cd926199e2271bf4f92.tar.gz scripts-115ff9a06870d51702918cd926199e2271bf4f92.zip | |
Added option to specify alternative menu. Some general cleanup.
Diffstat (limited to 'dmenu-dwm-sessionmanager')
| -rwxr-xr-x | dmenu-dwm-sessionmanager | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/dmenu-dwm-sessionmanager b/dmenu-dwm-sessionmanager index 74ddcf0..f423a09 100755 --- a/dmenu-dwm-sessionmanager +++ b/dmenu-dwm-sessionmanager | |||
| @@ -1,18 +1,26 @@ | |||
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | 2 | ||
| 3 | # Prompts menu to shutdown/reboot/close dwm | 3 | # Prompts menu to shutdown/reboot/close dwm |
| 4 | # Usage: dmenu-dwm-sessionmanager [-m menu] | ||
| 4 | # Requires: dmenu (or equivalent), dwm (optional) | 5 | # Requires: dmenu (or equivalent), dwm (optional) |
| 5 | 6 | ||
| 6 | menu=${MENU:-dmenu} | 7 | menu="dmenu -i" |
| 7 | menuopts="-i -p" | 8 | prompt="Do you want to quit?" |
| 8 | menuprompt="Do you want to quit?" | 9 | while getopts "m:" opt; do |
| 9 | wmname="dwm" | 10 | case "$opt" in |
| 11 | m) | ||
| 12 | menu="$OPTARG" | ||
| 13 | ;; | ||
| 14 | esac | ||
| 15 | done | ||
| 16 | shift `expr $OPTIND - 1` | ||
| 10 | 17 | ||
| 18 | wmname="dwm" | ||
| 11 | shutdown_cmd="sudo shutdown -h now" | 19 | shutdown_cmd="sudo shutdown -h now" |
| 12 | reboot_cmd="sudo reboot" | 20 | reboot_cmd="sudo reboot" |
| 13 | closewm_cmd="pkill $wmname" | 21 | closewm_cmd="pkill $wmname" |
| 14 | 22 | ||
| 15 | value=$(echo "Shutdown\nReboot\nQuit dwm" | $menu $menuopts "$menuprompt") | 23 | value=$(echo "Shutdown\nReboot\nQuit dwm" | $menu -p "$prompt") |
| 16 | 24 | ||
| 17 | if [ "$value" = "Shutdown" ]; then | 25 | if [ "$value" = "Shutdown" ]; then |
| 18 | $shutdown_cmd | 26 | $shutdown_cmd |
