.dotfiles/bin/dmenu_exit

40 lines
634 B
Bash
Executable File

#!/bin/bash
#
# a simple logout dialog
#
###
kill_apps() {
while read -r app; do
wmctrl -i -c "$app"
done < <(wmctrl -l | awk '{print $1}')
}
choice() {
if [[ -f "$HOME/.dmenurc" ]]; then
. "$HOME/.dmenurc"
DMENU="dmenu -i $dmenu_args"
else
DMENU='dmenu -i'
fi
choice=$(echo -e "0: Logout\n1: Shutdown\n2: Reboot\n3: Lock" | $DMENU | cut -d ':' -f 1)
}
[[ -z "$DISPLAY" ]] && exit 1
choice
[[ -z "$choice" ]] && exit 1
# gracefully close all open apps
#kill_apps
# execute the choice in background
case "$choice" in
0) i3-msg exit & ;;
1) poweroff & ;;
2) reboot & ;;
3) i3lock &
esac