| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- #!/bin/bash
- DIR="$HOME/.config/bspwm"
- rofi_command="rofi -theme $DIR/rofi/themes/powermenu.rasi"
- uptime=$(uptime -p | sed -e 's/up //g')
- # Options
- shutdown=""
- reboot=""
- lock=""
- suspend=""
- logout=""
- locker=i3lock -c 000000 && sleep 1
- # Variable passed to rofi
- options="$shutdown\n$reboot\n$lock\n$suspend\n$logout"
- _msg="Options - yes / y / no / n"
- chosen="$(echo -e "$options" | $rofi_command -p "UP - $uptime" -dmenu -selected-row 2)"
- case $chosen in
- $shutdown)
- ans=$($HOME/.config/bspwm/rofi/bin/confirm)
- if [[ $ans == "yes" ]] || [[ $ans == "YES" ]] || [[ $ans == "y" ]]; then
- systemctl poweroff
- elif [[ $ans == "no" ]] || [[ $ans == "NO" ]] || [[ $ans == "n" ]]; then
- exit
- else
- rofi -theme ~/.config/bspwm/rofi/themes/askpass.rasi -e "$_msg"
- fi
- ;;
- $reboot)
- ans=$($HOME/.config/bspwm/rofi/bin/confirm)
- if [[ $ans == "yes" ]] || [[ $ans == "YES" ]] || [[ $ans == "y" ]]; then
- systemctl reboot
- elif [[ $ans == "no" ]] || [[ $ans == "NO" ]] || [[ $ans == "n" ]]; then
- exit
- else
- rofi -theme ~/.config/bspwm/rofi/themes/askpass.rasi -e "$_msg"
- fi
- ;;
- $lock)
- $lock
- ;;
- $suspend)
- ans=$($HOME/.config/bspwm/rofi/bin/confirm)
- if [[ $ans == "yes" ]] || [[ $ans == "YES" ]] || [[ $ans == "y" ]]; then
- mpc -q pause
- amixer set Master mute
- betterlockscreen --suspend
- $Locker && systemctl hybrid-sleep
- elif [[ $ans == "no" ]] || [[ $ans == "NO" ]] || [[ $ans == "n" ]]; then
- exit
- else
- rofi -theme ~/.config/bspwm/rofi/themes/askpass.rasi -e "$_msg"
- fi
- ;;
- $logout)
- ans=$($HOME/.config/bspwm/rofi/bin/confirm)
- if [[ $ans == "yes" ]] || [[ $ans == "YES" ]] || [[ $ans == "y" ]]; then
- bspc quit
- elif [[ $ans == "no" ]] || [[ $ans == "NO" ]] || [[ $ans == "n" ]]; then
- exit
- else
- rofi -theme ~/.config/bspwm/rofi/themes/askpass.rasi -e "$_msg"
- fi
- ;;
- esac
|