powermenu 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/bash
  2. DIR="$HOME/.config/i3"
  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/i3/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/i3/rofi/themes/askpass.rasi -e "$_msg"
  25. fi
  26. ;;
  27. $reboot)
  28. ans=$($HOME/.config/i3/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/i3/rofi/themes/askpass.rasi -e "$_msg"
  35. fi
  36. ;;
  37. $lock)
  38. $lock
  39. ;;
  40. $suspend)
  41. ans=$($HOME/.config/i3/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/i3/rofi/themes/askpass.rasi -e "$_msg"
  51. fi
  52. ;;
  53. $logout)
  54. ans=$($HOME/.config/i3/rofi/bin/confirm)
  55. if [[ $ans == "yes" ]] || [[ $ans == "YES" ]] || [[ $ans == "y" ]]; then
  56. #bspc quit
  57. i3-msg exit, mode "default"
  58. elif [[ $ans == "no" ]] || [[ $ans == "NO" ]] || [[ $ans == "n" ]]; then
  59. exit
  60. else
  61. rofi -theme ~/.config/i3/rofi/themes/askpass.rasi -e "$_msg"
  62. fi
  63. ;;
  64. esac