diff --git a/dmenu/logout.sh b/dmenu/logout.sh new file mode 100644 index 0000000..652a747 --- /dev/null +++ b/dmenu/logout.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +args = "'$*' " +lines="-l 2" + +first_prompt="" +opt1="Restart\nShutdown" +opt2="Yes\nNo" + +ask() { + answer="$( echo -e $1 | dmenu -i -p "$2" $lines $args )" +} + +ask "$opt1" "$first_prompt" + +case $answer in + "Restart") + ask "$opt2" "Are you sure?" + if [[ $answer == "Sim" ]]; then + systemctl reboot + fi + exit 0 + ;; + "Shutdown") + ask "$opt2" "Are you sure?" + if [[ $answer == "Sim" ]]; then + systemctl poweroff + fi + exit 0 + ;; +esac + +exit 0 \ No newline at end of file