Created
June 7, 2012 20:43
-
-
Save menski/2891431 to your computer and use it in GitHub Desktop.
Thinkpad udev xrandr dock event
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
KERNEL=="dock.0", ACTION=="change", RUN+="/usr/sbin/thinkpad-dock" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# wait for the dock state to change | |
set -x | |
sleep 1 | |
DOCKED=$(cat /sys/devices/platform/dock.0/docked) | |
case "$DOCKED" in | |
"0") | |
#undocked event - lets remove all connected outputs apart from LVDS | |
for output in $(/usr/bin/xrandr -d :0.0 | grep " connected" | grep -v LVDS | awk '{print $1}') | |
do | |
/usr/bin/xrandr -d :0.0 --output $output --off | |
done | |
/usr/bin/xrandr -d :0.0 --output LVDS --auto | |
;; | |
"1") | |
#docked event - disable Laptop and setup dual monitor | |
/usr/bin/xrandr -d :0.0 --output LVDS --off | |
/usr/bin/xrandr -d :0.0 --output DVI-0 --auto --output VGA-0 --right-of DVI-0 --auto | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment