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.
 
 
 
 
 

36 lines
564 B

  1. #!/bin/bash
  2. function rotate
  3. {
  4. kill -10 `pidof waybar`
  5. }
  6. ROTFILE=/tmp/sway_rotation
  7. PREV=-1
  8. if [[ -f $ROTFILE ]]
  9. then
  10. PREV=$(<$ROTFILE)
  11. fi
  12. TRANSFORM=`swaymsg -p -t get_outputs | grep -A 15 "Output DSI-1" | grep "Transform:"`
  13. NOW=-1
  14. if [[ $TRANSFORM == *"normal"* ]]; then
  15. NOW=0
  16. elif [[ $TRANSFORM == *"90"* ]]; then
  17. NOW=1
  18. elif [[ $TRANSFORM == *"180"* ]]; then
  19. NOW=2
  20. elif [[ $TRANSFORM == *"270"* ]]; then
  21. NOW=3
  22. fi
  23. echo $NOW > $ROTFILE
  24. if [[ $(($PREV % 2)) -eq $(($NOW % 2)) ]]; then
  25. echo "No change."
  26. else
  27. echo Rotated from $PREV to $NOW.
  28. rotate
  29. fi