-
install arandr
sudo apt-get install arandr
-
save 2 configurations, one for monitors attached on docking, another for laptop only.
~/.screenlayout/dock.sh
~/.screenlayout/undock.sh
-
add new udev rule:
vi /etc/udev/rules.d/81-yourlaptop-dock.rules
KERNEL=="dock.0", ACTION=="change", RUN+="/YOURLOCATION/yourlaptop-dock.sh"
chmod +x /etc/udev/rules.d/81-yourlaptop-dock.rules
-
create /YOURLOCATION/yourlaptop-dock.sh (a script that should be run by the udev rule)
vi /YOURLOCATION/yourlaptop-dock.sh
#!/bin/bash
sleep 1
DOCKED=$(cat /sys/devices/platform/dock.0/docked)
case "$DOCKED" in
"0")
#undocked event
~/.screenlayout/undock.sh
;;
"1")
#docked event
~/.screenlayout/dock.sh
;;
esac
exit 0
chmod a+x /YOURLOCATION/yourlaptop-dock.sh