#!/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