Archlinux basic installation configuration scripts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
2.2 KiB

  1. #!/usr/bin/env bash
  2. ## Author : Aditya Shakya
  3. ## Mail : adi1090x@gmail.com
  4. ## Github : @adi1090x
  5. ## Twitter : @adi1090x
  6. dir="~/.config/polybar/material/scripts/rofi"
  7. uptime=$(uptime -p | sed -e 's/up //g')
  8. rofi_command="rofi -theme $dir/powermenu.rasi"
  9. # Options
  10. shutdown=" Shutdown"
  11. reboot=" Restart"
  12. lock=" Lock"
  13. suspend=" Sleep"
  14. logout=" Logout"
  15. # Confirmation
  16. confirm_exit() {
  17. rofi -dmenu\
  18. -i\
  19. -no-fixed-num-lines\
  20. -p "Are You Sure? : "\
  21. -theme $dir/confirm.rasi
  22. }
  23. # Message
  24. msg() {
  25. rofi -theme "$dir/message.rasi" -e "Available Options - yes / y / no / n"
  26. }
  27. # Variable passed to rofi
  28. options="$lock\n$suspend\n$logout\n$reboot\n$shutdown"
  29. chosen="$(echo -e "$options" | $rofi_command -p "Uptime: $uptime" -dmenu -selected-row 0)"
  30. case $chosen in
  31. $shutdown)
  32. ans=$(confirm_exit &)
  33. if [[ $ans == "yes" || $ans == "YES" || $ans == "y" || $ans == "Y" ]]; then
  34. systemctl poweroff
  35. elif [[ $ans == "no" || $ans == "NO" || $ans == "n" || $ans == "N" ]]; then
  36. exit 0
  37. else
  38. msg
  39. fi
  40. ;;
  41. $reboot)
  42. ans=$(confirm_exit &)
  43. if [[ $ans == "yes" || $ans == "YES" || $ans == "y" || $ans == "Y" ]]; then
  44. systemctl reboot
  45. elif [[ $ans == "no" || $ans == "NO" || $ans == "n" || $ans == "N" ]]; then
  46. exit 0
  47. else
  48. msg
  49. fi
  50. ;;
  51. $lock)
  52. if [[ -f /usr/bin/i3lock ]]; then
  53. i3lock
  54. elif [[ -f /usr/bin/betterlockscreen ]]; then
  55. betterlockscreen -l
  56. fi
  57. ;;
  58. $suspend)
  59. ans=$(confirm_exit &)
  60. if [[ $ans == "yes" || $ans == "YES" || $ans == "y" || $ans == "Y" ]]; then
  61. mpc -q pause
  62. amixer set Master mute
  63. systemctl suspend
  64. elif [[ $ans == "no" || $ans == "NO" || $ans == "n" || $ans == "N" ]]; then
  65. exit 0
  66. else
  67. msg
  68. fi
  69. ;;
  70. $logout)
  71. ans=$(confirm_exit &)
  72. if [[ $ans == "yes" || $ans == "YES" || $ans == "y" || $ans == "Y" ]]; then
  73. if [[ "$DESKTOP_SESSION" == "Openbox" ]]; then
  74. openbox --exit
  75. elif [[ "$DESKTOP_SESSION" == "bspwm" ]]; then
  76. bspc quit
  77. elif [[ "$DESKTOP_SESSION" == "i3" ]]; then
  78. i3-msg exit
  79. fi
  80. elif [[ $ans == "no" || $ans == "NO" || $ans == "n" || $ans == "N" ]]; then
  81. exit 0
  82. else
  83. msg
  84. fi
  85. ;;
  86. esac