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.

47 lines
1.7KB

  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|⚿ Yubico Authenticator|↻ Reload Sway|↻ Reload Waybar|↩ Logout|↯ 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 1D2021
  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" == "⚿ Yubico Authenticator" ]; then
  23. /home/jpm/scripts/rofi/rofi-yubioath.sh
  24. elif [ "$res" == "↻ Reload i3" ]; then
  25. i3 reload
  26. elif [ "$res" == "↹ Restart i3" ]; then
  27. i3 restart
  28. elif [ "$res" == "↻ Reload Sway" ]; then
  29. sway reload
  30. elif [ "$res" == "↻ Reload Waybar" ]; then
  31. # Need to integrate with sway/displays.pl for alternative outputs
  32. /home/jpm/scripts/sway/displays.pl -w
  33. elif [ "$res" == "🡙 Reboot" ]; then
  34. rm $SSH_AUTH_SOCK
  35. sudo systemctl reboot -i
  36. elif [ "$res" == "⏻ Shutdown" ]; then
  37. rm $SSH_AUTH_SOCK
  38. sudo systemctl poweroff -i
  39. elif [ "$res" == "↯ Hibernate" ]; then
  40. sudo systemctl hibernate -i
  41. fi
  42. exit 0