A variety of simple automation scripts and enhancements to Sway and i3.
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.

45 lines
1.6KB

  1. #!/bin/bash
  2. # Passwordless sudo required for systemctl [reboot|poweroff|hibernate]
  3. # Determine if Sway or i3
  4. if [ -z ${SWAYSOCK+x} ]; then
  5. WM="i3"
  6. else
  7. WM="sway"
  8. fi
  9. if [[ $WM == 'i3' ]]; then
  10. res=$(printf "🔒 Lock|↩ Logout|↻ Reload i3|↹ Restart i3|↯ Hibernate|🡙 Reboot|⏻ Shutdown" | rofi -sep "|" -dmenu -i -p 'Power: ' "" -columns 1 -rows 7 -width 32 -l 1 -hide-scrollbar -eh 1 -location 0 -padding 12 -opacity 100 -auto-select -no-fullscreen)
  11. else
  12. res=$(echo "🔒 Lock|🖵 Toggle Displays|↩ Logout|↻ Reload Sway|↻ Reload Waybar|↯ Hibernate|🡙 Reboot|⏻ Shutdown" | rofi -sep "|" -dmenu -i -p 'Power: ' "" -no-lazy-grab -auto-select -no-fullscreen)
  13. fi
  14. if [ "$res" == "🔒 Lock" ]; then
  15. ${WM}lock -c 323232
  16. elif [ "$res" == "↩ Logout" ]; then
  17. # Prevent auto-login
  18. rm /home/jpm/.config/last_login_gui
  19. ${WM} exit
  20. elif [ "$res" == "🖵 Toggle Displays" ]; then
  21. /home/jpm/scripts/sway/toggle_outputs.sh
  22. elif [ "$res" == "↻ Reload i3" ]; then
  23. i3 reload
  24. elif [ "$res" == "↹ Restart i3" ]; then
  25. i3 restart
  26. elif [ "$res" == "↻ Reload Sway" ]; then
  27. sway reload
  28. elif [ "$res" == "↻ Reload Waybar" ]; then
  29. # Need to integrate with sway/displays.pl for alternative outputs
  30. /home/jpm/scripts/sway/displays.pl -w
  31. elif [ "$res" == "🡙 Reboot" ]; then
  32. rm $SSH_AUTH_SOCK
  33. sudo systemctl reboot -i
  34. elif [ "$res" == "⏻ Shutdown" ]; then
  35. rm $SSH_AUTH_SOCK
  36. sudo systemctl poweroff -i
  37. elif [ "$res" == "↯ Hibernate" ]; then
  38. sudo systemctl hibernate -i
  39. fi
  40. exit 0