diff --git a/files/powermenu/type-1/powermenu.sh b/files/powermenu/type-1/powermenu.sh index 0e773be..b8dccc2 100755 --- a/files/powermenu/type-1/powermenu.sh +++ b/files/powermenu/type-1/powermenu.sh @@ -14,101 +14,119 @@ dir="$HOME/.config/rofi/powermenu/type-1" theme='style-1' # CMDs -uptime="`uptime -p | sed -e 's/up //g'`" -host=`hostname` +uptime="$(uptime -p | sed -e 's/up //g')" +host=$(hostname) # Options shutdown=' Shutdown' reboot=' Reboot' lock=' Lock' suspend=' Suspend' +hibernate='󰒲 Hibernate' +hybrid='󰜎 Hybrid Sleep' +susbernate=' Suspend then Hibernate' logout=' Logout' yes=' Yes' no=' No' # Rofi CMD rofi_cmd() { - rofi -dmenu \ - -p "$host" \ - -mesg "Uptime: $uptime" \ - -theme ${dir}/${theme}.rasi + rofi -dmenu \ + -p "$host" \ + -mesg "Uptime: $uptime" \ + -theme ${dir}/${theme}.rasi } # Confirmation CMD confirm_cmd() { - rofi -theme-str 'window {location: center; anchor: center; fullscreen: false; width: 250px;}' \ - -theme-str 'mainbox {children: [ "message", "listview" ];}' \ - -theme-str 'listview {columns: 2; lines: 1;}' \ - -theme-str 'element-text {horizontal-align: 0.5;}' \ - -theme-str 'textbox {horizontal-align: 0.5;}' \ - -dmenu \ - -p 'Confirmation' \ - -mesg 'Are you Sure?' \ - -theme ${dir}/${theme}.rasi + rofi -theme-str 'window {location: center; anchor: center; fullscreen: false; width: 250px;}' \ + -theme-str 'mainbox {children: [ "message", "listview" ];}' \ + -theme-str 'listview {columns: 2; lines: 1;}' \ + -theme-str 'element-text {horizontal-align: 0.5;}' \ + -theme-str 'textbox {horizontal-align: 0.5;}' \ + -dmenu \ + -p 'Confirmation' \ + -mesg 'Are you Sure?' \ + -theme ${dir}/${theme}.rasi } # Ask for confirmation confirm_exit() { - echo -e "$yes\n$no" | confirm_cmd + echo -e "$yes\n$no" | confirm_cmd } # Pass variables to rofi dmenu run_rofi() { - echo -e "$lock\n$suspend\n$logout\n$reboot\n$shutdown" | rofi_cmd + echo -e "$lock\n$suspend\n$hibernate\n$reboot\n$shutdown\n$hybrid\n$susbernate\n$logout" | rofi_cmd } # Execute Command run_cmd() { - selected="$(confirm_exit)" - if [[ "$selected" == "$yes" ]]; then - if [[ $1 == '--shutdown' ]]; then - systemctl poweroff - elif [[ $1 == '--reboot' ]]; then - systemctl reboot - elif [[ $1 == '--suspend' ]]; then - mpc -q pause - amixer set Master mute - systemctl suspend - elif [[ $1 == '--logout' ]]; then - if [[ "$DESKTOP_SESSION" == 'openbox' ]]; then - openbox --exit - elif [[ "$DESKTOP_SESSION" == 'bspwm' ]]; then - bspc quit - elif [[ "$DESKTOP_SESSION" == 'i3' ]]; then - i3-msg exit - elif [[ "$DESKTOP_SESSION" == 'plasma' ]]; then - qdbus org.kde.ksmserver /KSMServer logout 0 0 0 - elif [[ "$DESKTOP_SESSION" == 'hyprland' ]]; then - hyprctl dispatch exit - fi - fi - else - exit 0 - fi + selected="$(confirm_exit)" + if [[ "$selected" == "$yes" ]]; then + if [[ $1 == '--shutdown' ]]; then + systemctl poweroff + elif [[ $1 == '--reboot' ]]; then + systemctl reboot + elif [[ $1 == '--suspend' ]]; then + mpc -q pause + amixer set Master mute + systemctl suspend + elif [[ $1 == '--hibernate' ]]; then + systemctl hibernate + elif [[ $1 == '--hybrid' ]]; then + systemctl hybrid-sleep + elif [[ $1 == '--susbernate' ]]; then + systemctl suspend-then-hibernate + elif [[ $1 == '--logout ' ]]; then + if [[ "$DESKTOP_SESSION" == 'openbox' ]]; then + openbox --exit + elif [[ "$DESKTOP_SESSION" == 'bspwm' ]]; then + bspc quit + elif [[ "$DESKTOP_SESSION" == 'i3' ]]; then + i3-msg exit + elif [[ "$DESKTOP_SESSION" == 'plasma' ]]; then + qdbus org.kde.ksmserver /KSMServer logout 0 0 0 + elif [[ "$DESKTOP_SESSION" == 'hyprland' ]]; then + hyprctl dispatch exit + fi + fi + else + exit 0 + fi } # Actions chosen="$(run_rofi)" case ${chosen} in - $shutdown) - run_cmd --shutdown - ;; - $reboot) - run_cmd --reboot - ;; - $lock) - if [[ -x '/usr/bin/betterlockscreen' ]]; then - betterlockscreen -l - elif [[ -x '/usr/bin/i3lock' ]]; then - i3lock - elif [[ -x '/usr/bin/hyprlock' ]]; then - hyprlock - fi - ;; - $suspend) - run_cmd --suspend - ;; - $logout) - run_cmd --logout - ;; +$shutdown) + run_cmd --shutdown + ;; +$reboot) + run_cmd --reboot + ;; +$lock) + if [[ -x '/usr/bin/betterlockscreen' ]]; then + betterlockscreen -l + elif [[ -x '/usr/bin/i3lock' ]]; then + i3lock + elif [[ -x '/usr/bin/hyprlock' ]]; then + hyprlock + fi + ;; +$suspend) + run_cmd --suspend + ;; +$hibernate) + run_cmd --hibernate + ;; +$hybrid) + run_cmd --hybrid + ;; +$susbernate) + run_cmd --susbernate + ;; +$logout) + run_cmd --logout + ;; esac