Last active
December 15, 2015 12:09
-
-
Save taylor/5257927 to your computer and use it in GitHub Desktop.
script to rotate your screen... currently only supporting laptop display
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Usage: rotate-screen [absolute] [action] | |
| # | |
| # ACTIONS: | |
| # flip|invert - invert the screen from the current rotation | |
| # left - rotate to the left | |
| # right - rotate to the right | |
| # | |
| # OPTION: | |
| # absolute - this forces the rotation to be relative to "normal" rotation vs current | |
| default_output="LVDS1" | |
| default_rotation="normal" | |
| read -a foo <<< $(xrandr -q |grep " connected" |head -n 1| awk '{print $1" "$4}') | |
| output=${foo[0]} | |
| cr=${foo[1]} | |
| case $cr in | |
| l) current_rotation="left" ;; | |
| r) current_rotation="right" ;; | |
| i) current_rotation="inverted" ;; | |
| *) current_rotation="normal" ;; | |
| esac | |
| # Act like we are in normal mode so the switch will go to the default rotation | |
| if [ "$1" = "absolute" ] ; then | |
| current_rotation=normal | |
| shift | |
| fi | |
| case $1 in | |
| flip|inverted|invert) | |
| case $current_rotation in | |
| left) rotation="right" ;; | |
| right) rotation="left" ;; | |
| normal) rotation="inverted" ;; | |
| #inverted) rotation="normal" ;; | |
| *) rotation="normal" ;; | |
| esac | |
| ;; | |
| upsidedown|forfriend|look) | |
| rotation="inverted" | |
| ;; | |
| left) | |
| case $current_rotation in | |
| left) rotation="inverted" ;; | |
| inverted) rotation="right" ;; | |
| right) rotation="normal" ;; | |
| *) rotation="left" ;; | |
| esac | |
| ;; | |
| right) | |
| case $current_rotation in | |
| right) rotation="inverted" ;; | |
| inverted) rotation="left" ;; | |
| left) rotation="normal" ;; | |
| *) rotation="right" ;; | |
| esac | |
| ;; | |
| *) | |
| rotation="normal" | |
| ;; | |
| esac | |
| xrandr --output "$output" --rotate "$rotation" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment