blob: 7217a14acb58b1103e777f5faa2fbd8b2da25914 (
plain) (
blame)
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
52
53
54
55
56
57
58
59
60
61
|
#!/bin/bash
SwayLock=$HOME/.config/hypr/scripts/LockScreen.sh
# CMDs
uptime_info=$(uptime -p | sed -e 's/up //g')
host=$(hostnamectl hostname)
# Options with Icons and Text
options=("Lock(l)" "Suspend(u)" "Logout(e)" "Reboot(r)" "Shutdown(s)" "Hibernate(h)")
icons=("" "" "" "" "" "")
# Rofi CMD
rofi_cmd() {
options_with_icons=()
for ((i = 0; i < ${#options[@]}; i++)); do
options_with_icons+=("${icons[$i]} ${options[$i]}")
done
chosen_option=$(printf "%s\n" "${options_with_icons[@]}" | \
rofi -dmenu -i -p " $USER@$host" -mesg " Uptime: $uptime_info" \
-kb-select-1 "l" \
-kb-select-2 "u" \
-kb-select-3 "e" \
-kb-select-4 "r" \
-kb-select-5 "s" \
-kb-select-6 "h" \
-theme ~/.config/rofi/config-powermenu.rasi | awk '{print $1}')
echo "$chosen_option"
}
# Execute Command
run_cmd() {
case $1 in
"")
$SwayLock &
;;
"")
systemctl suspend
;;
"")
hyprctl dispatch exit 0
;;
"")
systemctl reboot
;;
"")
systemctl poweroff
;;
"")
systemctl hibernate
;;
*)
echo "choose: $1"
;;
esac
}
# Actions
chosen_option=$(rofi_cmd)
run_cmd "${chosen_option% *}"
|