]> git.donarmstrong.com Git - bin.git/commitdiff
add rotate monitor
authorDon Armstrong <don@donarmstrong.com>
Wed, 16 Jul 2014 00:56:52 +0000 (17:56 -0700)
committerDon Armstrong <don@donarmstrong.com>
Wed, 16 Jul 2014 00:56:52 +0000 (17:56 -0700)
rotate_monitor [new file with mode: 0755]

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;