powermenu (1976B)
1 #!/bin/bash 2 3 DIR="$HOME/.config/bspwm" 4 5 rofi_command="rofi -theme $DIR/rofi/themes/powermenu.rasi" 6 7 uptime=$(uptime -p | sed -e 's/up //g') 8 9 # Options 10 shutdown="" 11 reboot="" 12 lock="" 13 suspend="" 14 logout="" 15 16 # Variable passed to rofi 17 options="$shutdown\n$reboot\n$lock\n$suspend\n$logout" 18 _msg="Options - yes / y / no / n" 19 20 chosen="$(echo -e "$options" | $rofi_command -p "UP - $uptime" -dmenu -selected-row 2)" 21 case $chosen in 22 $shutdown) 23 ans=$($HOME/.config/bspwm/rofi/bin/confirm) 24 if [[ $ans == "yes" ]] || [[ $ans == "YES" ]] || [[ $ans == "y" ]]; then 25 systemctl poweroff 26 elif [[ $ans == "no" ]] || [[ $ans == "NO" ]] || [[ $ans == "n" ]]; then 27 exit 28 else 29 rofi -theme ~/.config/bspwm/rofi/themes/askpass.rasi -e "$_msg" 30 fi 31 ;; 32 $reboot) 33 ans=$($HOME/.config/bspwm/rofi/bin/confirm) 34 if [[ $ans == "yes" ]] || [[ $ans == "YES" ]] || [[ $ans == "y" ]]; then 35 systemctl reboot 36 elif [[ $ans == "no" ]] || [[ $ans == "NO" ]] || [[ $ans == "n" ]]; then 37 exit 38 else 39 rofi -theme ~/.config/bspwm/rofi/themes/askpass.rasi -e "$_msg" 40 fi 41 ;; 42 $lock) 43 betterlockscreen --lock 44 ;; 45 $suspend) 46 ans=$($HOME/.config/bspwm/rofi/bin/confirm) 47 if [[ $ans == "yes" ]] || [[ $ans == "YES" ]] || [[ $ans == "y" ]]; then 48 mpc -q pause 49 amixer set Master mute 50 betterlockscreen --suspend 51 elif [[ $ans == "no" ]] || [[ $ans == "NO" ]] || [[ $ans == "n" ]]; then 52 exit 53 else 54 rofi -theme ~/.config/bspwm/rofi/themes/askpass.rasi -e "$_msg" 55 fi 56 ;; 57 $logout) 58 ans=$($HOME/.config/bspwm/rofi/bin/confirm) 59 if [[ $ans == "yes" ]] || [[ $ans == "YES" ]] || [[ $ans == "y" ]]; then 60 bspc quit 61 elif [[ $ans == "no" ]] || [[ $ans == "NO" ]] || [[ $ans == "n" ]]; then 62 exit 63 else 64 rofi -theme ~/.config/bspwm/rofi/themes/askpass.rasi -e "$_msg" 65 fi 66 ;; 67 esac 68