]> git.donarmstrong.com Git - bin.git/commitdiff
add thinkpad doc
authorDon Armstrong <don@donarmstrong.com>
Sun, 12 Oct 2014 18:00:17 +0000 (11:00 -0700)
committerDon Armstrong <don@donarmstrong.com>
Sun, 12 Oct 2014 18:00:17 +0000 (11:00 -0700)
thinkpad_doc [new file with mode: 0755]

diff --git a/thinkpad_doc b/thinkpad_doc
new file mode 100755 (executable)
index 0000000..83ea4a6
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/sh
+# The idea for this was taken from
+# https://gist.github.com/menski/2891431 and modified slightly
+
+# wait for the dock state to change
+set -x
+# use the xdm xauthority
+XAUTHORITY="$(ls -1 /var/lib/xdm/authdir/authfiles/*|head -n1)"
+export XAUTHORITY
+DISPLAY=":0.0"
+export DISPLAY
+sleep 1
+DOCKED=$(cat /sys/devices/platform/dock.2/docked)
+case "$DOCKED" in
+    "0")
+        #undocked event - lets remove all connected outputs apart from LVDS
+        for output in $(/usr/bin/xrandr | grep " connected" | grep -v LVDS | awk '{print $1}')
+        do
+            /usr/bin/xrandr --output $output --off
+        done
+        for output in $(/usr/bin/xrandr | grep " connected" | grep LVDS | awk '{print $1}')
+        do
+            /usr/bin/xrandr --output $output --auto
+        done
+        ;;
+    "1")
+        # docked event; enable all of the screens
+        /usr/bin/xrandr --auto
+        ;;
+esac
+exit 0