]> git.donarmstrong.com Git - bin.git/blob - thinkpad_doc
add reset usb bus command
[bin.git] / thinkpad_doc
1 #!/bin/sh
2  
3 # The idea for this was taken from
4 # https://gist.github.com/menski/2891431 and modified slightly
5
6 # wait for the dock state to change
7 set -x
8 # use the xdm xauthority
9 XAUTHORITY="$(ls -1 /var/lib/xdm/authdir/authfiles/*|head -n1)"
10 export XAUTHORITY
11 DISPLAY=":0.0"
12 export DISPLAY
13 sleep 1
14 DOCKED=$(cat /sys/devices/platform/dock.2/docked)
15 case "$DOCKED" in
16     "0")
17         #undocked event - lets remove all connected outputs apart from LVDS
18         for output in $(/usr/bin/xrandr | grep " connected" | grep -v LVDS | awk '{print $1}')
19         do
20             /usr/bin/xrandr --output $output --off
21         done
22         for output in $(/usr/bin/xrandr | grep " connected" | grep LVDS | awk '{print $1}')
23         do
24             /usr/bin/xrandr --output $output --auto
25         done
26         ;;
27     "1")
28         # docked event; enable all of the screens
29         /usr/bin/xrandr --auto
30         ;;
31 esac
32 exit 0