diff options
Diffstat (limited to 'config/hypr/scripts')
| -rwxr-xr-x | config/hypr/scripts/RofiPower.sh | 67 | ||||
| -rwxr-xr-x | config/hypr/scripts/rofipower.sh | 67 |
2 files changed, 67 insertions, 67 deletions
diff --git a/config/hypr/scripts/RofiPower.sh b/config/hypr/scripts/RofiPower.sh new file mode 100755 index 00000000..824cffa3 --- /dev/null +++ b/config/hypr/scripts/RofiPower.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env 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" "Suspend" "Logout" "Reboot" "Shutdown" "Hibernate") +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" +} + +# Pass variables to rofi dmenu +run_rofi() { + chosen_option=$(rofi_cmd) + 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=$(run_rofi) +run_cmd "${chosen_option% *}"
\ No newline at end of file diff --git a/config/hypr/scripts/rofipower.sh b/config/hypr/scripts/rofipower.sh deleted file mode 100755 index 7bb70e9c..00000000 --- a/config/hypr/scripts/rofipower.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env bash - -# Swayconfig -SWAYCONFIG="$HOME/.config/swaylock/config" - -# CMDs -uptime="`uptime -p | sed -e 's/up //g'`" -host=`hostnamectl hostname` - -# Options -shutdown=' Shutdown' -reboot=' Reboot' -lock=' Lock' -suspend=' Suspend' -logout=' Logout' -hibernate=' Hibernate' - -# Rofi CMD -rofi_cmd() { - rofi -dmenu -p " $USER@$host" -mesg " Uptime: $uptime" -sep '|' -eh 2 -theme ~/.config/rofi/config-powermenu.rasi -} - -# Pass variables to rofi dmenu -run_rofi() { - echo -e "$lock\0meta\x1fl|$suspend\0meta\x1fu|$logout\0meta\x1fe|$reboot\0meta\x1fr|$shutdown\0meta\x1fs|$hibernate\0meta\x1fh" | rofi_cmd -} - -# Execute Command -run_cmd() { - if [[ $1 == '--shutdown' ]]; then - systemctl poweroff - elif [[ $1 == '--reboot' ]]; then - systemctl reboot - elif [[ $1 == '--suspend' ]]; then - systemctl suspend - elif [[ $1 == '--logout' ]]; then - hyprctl dispatch exit 0 - elif [[ $1 == '--hibernate' ]]; then - systemctl hibernate - fi -} - -# Actions -chosen="$(run_rofi)" -case ${chosen} in - $shutdown) - run_cmd --shutdown - ;; - $reboot) - run_cmd --reboot - ;; - $hibernate) - run_cmd --hibernate - ;; - $lock) - sleep 0.5s; swaylock --config ${SWAYCONFIG} & disown - ;; - $suspend) - run_cmd --suspend - ;; - $logout) - run_cmd --logout - ;; - $hibernate) - run_cmd --hibernate - ;; -esac
\ No newline at end of file |
