search

Automatically Change Screen Layout when Docked

Tue, Dec 3, 2019 00:50 CET

Tags: Automation, udev

Layout settings can be automated depending on connected monitors.

Install autorandr and configure it for the relevant users.

TODO ACTUALLY I DISABLED THAT RULE AND IT STILL WORKS… I HAVE NO IDEA WHAT TRIGGERS AUTORANDR

Setup a udev rule to trigger when docking/undocking.

# /etc/udev/rules.d/50-dock.rules

ACTION=="change", BUS="usb", ATTRS{idVendor}=="<idVendor>", ATTRS{idProduct}=="<idProduct>", NAME="dock", RUN="autorandr --batch --change"

The dock id’s can be found via lsusb.

lsusb

Reload rules.

udevadm control --reload-rules

Note that a more flexible solution is to define a service or shell script that calls other, possibly multiple, scripts.

One can also handle the actions add and remove with different

See