From: Don Armstrong Date: Sun, 12 Oct 2014 18:00:17 +0000 (-0700) Subject: add thinkpad doc X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=c1b2f3b46a0b3c7a089bff793b8c4bcb77c37967;p=bin.git add thinkpad doc --- diff --git a/thinkpad_doc b/thinkpad_doc new file mode 100755 index 0000000..83ea4a6 --- /dev/null +++ b/thinkpad_doc @@ -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