]> git.donarmstrong.com Git - bin.git/blobdiff - rotate_monitor
add rotate monitor
[bin.git] / rotate_monitor
diff --git a/rotate_monitor b/rotate_monitor
new file mode 100755 (executable)
index 0000000..5df04f5
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+# rotate all of the attached displays
+
+XRANDR_OUTPUT=$(xrandr -q)
+
+OUTPUTS=$(echo "$XRANDR_OUTPUT" |awk '/ connected /{print $1}')
+
+set -x
+
+for output in $OUTPUTS; do
+    NEW_ORIENTATION="left"
+    # figure out current orientation
+    ORIENTATION=$(echo "$XRANDR_OUTPUT"|grep "^$output "|awk '{print $4}')
+    if [ "x$ORIENTATION" = "xleft" ]; then
+        NEW_ORIENTATION="inverted";
+    elif [ "x$ORIENTATION" = "xinverted" ]; then
+        NEW_ORIENTATION="right";
+    elif [ "x$ORIENTATION" = "xright" ]; then
+        NEW_ORIENTATION="normal";
+    else
+        NEW_ORIENTATION="left";
+    fi;
+    xrandr --output $OUTPUTS --rotate $NEW_ORIENTATION;
+done;