From ca968c4e5040f1ff4b5b5e12d9312360d807dcc1 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Mon, 3 Jun 2024 19:56:39 +0800 Subject: added submodules, change . -> dot (see man stow --dotfiles) --- dot-config/rofi/scripts/rofi_shutdown_menu | 52 ++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 dot-config/rofi/scripts/rofi_shutdown_menu (limited to 'dot-config/rofi/scripts/rofi_shutdown_menu') diff --git a/dot-config/rofi/scripts/rofi_shutdown_menu b/dot-config/rofi/scripts/rofi_shutdown_menu new file mode 100755 index 00000000..a396189b --- /dev/null +++ b/dot-config/rofi/scripts/rofi_shutdown_menu @@ -0,0 +1,52 @@ +#!/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 +yes='' +no='' + +# Confirmation CMD +confirm_cmd() { + rofi -dmenu \ + -p 'Confirmation' \ + -mesg 'Confirmation?' \ + -theme ${CNFR} +} + +run_rofi() { + echo -e "$yes\n$no" | confirm_cmd +} + +# Confirm and execute +confirm_run () { + selected="$(run_rofi)" + if [[ "$selected" == "" || "$selected" == "$no" ]]; then + notify-send "Canceled shutdown process." + exit + elif [[ "$selected" == "$yes" ]]; then + poweroff + fi +} + +confirm_run & +pid=$! +#pid=$(cat /run/user/$(id -u)/rofi.pid) +notify-send "Powering off system in 10 seconds" +for (( i = 10; 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 -- cgit v1.2.3