-
-
Save jagipson/5262784 to your computer and use it in GitHub Desktop.
This file contains 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 | |
: ${output:="LVDS1"} | |
: ${default_rotation:="normal"} | |
cr=$(xrandr -q |grep " connected" | awk '{print $4}' | cut -b 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