diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2024-06-03 19:56:39 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2024-06-03 19:56:39 +0800 |
| commit | ca968c4e5040f1ff4b5b5e12d9312360d807dcc1 (patch) | |
| tree | 9900920e8f566794560c1519678e344351d2803b /dot-config/rofi/scripts/rofi_shutdown | |
| parent | 5f3deaff0bf006a1a353e57b82ad48c0e8f143bc (diff) | |
added submodules, change . -> dot (see man stow --dotfiles)
Diffstat (limited to 'dot-config/rofi/scripts/rofi_shutdown')
| -rwxr-xr-x | dot-config/rofi/scripts/rofi_shutdown | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/dot-config/rofi/scripts/rofi_shutdown b/dot-config/rofi/scripts/rofi_shutdown new file mode 100755 index 00000000..b17f7667 --- /dev/null +++ b/dot-config/rofi/scripts/rofi_shutdown @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +# Import Current Theme +DIR="$HOME/.config/rofi" +CNFR="$DIR/confirm.rasi" + +# Theme Elements +prompt="`hostname` (`echo $DESKTOP_SESSION`)" +mesg="Uptime : `uptime -p | sed -e 's/up //g'`" + +# Options +no='' + +# Confirmation CMD +confirm_cmd() { + rofi -dmenu \ + -p 'Confirmation' \ + -mesg 'Cancel?' \ + -theme ${CNFR} +} + +run_rofi() { + echo -e "$no" | confirm_cmd +} + +# Confirm and execute +confirm_run () { + selected="$(run_rofi)" + if [[ "$selected" || "$selected" == "" ]]; then + exit + else + echo "Error had occured" + exit 1 + fi +} + +confirm_run & +pid=$! +#pid=$(cat /run/user/$(id -u)/rofi.pid) +notify-send "Powering off system in 10 seconds" +for (( i = 9; i >= 0; --i )); do + if ! ps -p $pid > /dev/null; then + notify-send "Canceled shutdown process." + exit 0 + fi + notify-send "Powering off system in $i" + sleep 1 +done +if ps -p $pid > /dev/null; then + poweroff +fi |
