powermenu 2.0 KB

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