powermenu (2467B)
1 #!/bin/bash 2 3 # Available Styles 4 # >> Styles Below Only Works With "rofi-git(AUR)", Tested On Version: 1.5.4-76-gca067234 5 # full full_circle full_rounded full_alt 6 # card card_circle column column_circle 7 # row row_alt row_circle 8 # single single_circle single_full single_full_circle single_rounded single_text 9 10 ## Default 11 DIR="default" 12 STYLE="powermenu" 13 14 rofi_command="rofi -theme $DIR/$STYLE.rasi" 15 16 uptime=$(uptime -p | sed -e 's/up //g') 17 18 # Options 19 if [[ "$DIR" == "powermenus" ]]; then 20 shutdown="" 21 reboot="" 22 lock="" 23 suspend="" 24 logout="" 25 ddir="$HOME/.config/rofi/$DIR" 26 else 27 shutdown=" Shutdown" 28 reboot=" Restart" 29 lock=" Lock" 30 suspend=" Sleep" 31 logout=" Logout" 32 ddir="$HOME/.config/rofi/dialogs" 33 fi 34 35 rdialog () { 36 rofi -dmenu\ 37 -i\ 38 -no-fixed-num-lines\ 39 -p "Are You Sure? : "\ 40 -theme "$ddir/confirm.rasi" 41 } 42 43 # Variable passed to rofi 44 MSG="Options : yes/no/y/n" 45 options="$lock\n$suspend\n$logout\n$reboot\n$shutdown" 46 47 chosen="$(echo -e "$options" | $rofi_command -p "UP - $uptime" -dmenu -selected-row 0)" 48 case $chosen in 49 $shutdown) 50 ans=$(rdialog) 51 if [[ $ans == "yes" ]] || [[ $ans == "YES" ]] || [[ $ans == "y" ]]; then 52 systemctl poweroff 53 elif [[ $ans == "no" ]] || [[ $ans == "NO" ]] || [[ $ans == "n" ]]; then 54 exit 55 else 56 rofi -theme "$ddir/confirm.rasi" -e "$MSG" 57 fi 58 ;; 59 $reboot) 60 ans=$(rdialog) 61 if [[ $ans == "yes" ]] || [[ $ans == "YES" ]] || [[ $ans == "y" ]]; then 62 systemctl reboot 63 elif [[ $ans == "no" ]] || [[ $ans == "NO" ]] || [[ $ans == "n" ]]; then 64 exit 65 else 66 rofi -theme "$ddir/confirm.rasi" -e "$MSG" 67 fi 68 ;; 69 $lock) 70 betterlockscreen --lock 71 ;; 72 $suspend) 73 ans=$(rdialog) 74 if [[ $ans == "yes" ]] || [[ $ans == "YES" ]] || [[ $ans == "y" ]]; then 75 mpc -q pause 76 amixer set Master mute 77 betterlockscreen --suspend 78 elif [[ $ans == "no" ]] || [[ $ans == "NO" ]] || [[ $ans == "n" ]]; then 79 exit 80 else 81 rofi -theme "$ddir/confirm.rasi" -e "$MSG" 82 fi 83 ;; 84 $logout) 85 ans=$(rdialog) 86 if [[ $ans == "yes" ]] || [[ $ans == "YES" ]] || [[ $ans == "y" ]]; then 87 openbox --exit 88 elif [[ $ans == "no" ]] || [[ $ans == "NO" ]] || [[ $ans == "n" ]]; then 89 exit 90 else 91 rofi -theme "$ddir/confirm.rasi" -e "$MSG" 92 fi 93 ;; 94 esac 95