Skip to content

Instantly share code, notes, and snippets.

@menski
Created June 7, 2012 20:43
Show Gist options
  • Save menski/2891431 to your computer and use it in GitHub Desktop.
Save menski/2891431 to your computer and use it in GitHub Desktop.
Thinkpad udev xrandr dock event
KERNEL=="dock.0", ACTION=="change", RUN+="/usr/sbin/thinkpad-dock"
#!/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