blob: b17f7667b506c8d691f7f0cff2aa0a6c9db48f74 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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
|