When plugging my Dell XPS13 (9360) to my TB16, which is connected to 2x 4k monitors, I want to turn off my laptop monitor. When unplugging the laptop from the docking, I want to turn the laptop monitor back-on.
4.20.2-1-default
NAME="openSUSE Tumbleweed"
# VERSION="20190126"
ID="opensuse-tumbleweed"
ID_LIKE="opensuse suse"
VERSION_ID="20190126"
PRETTY_NAME="openSUSE Tumbleweed"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:opensuse:tumbleweed:20190126"
BUG_REPORT_URL="https://bugs.opensuse.org"
HOME_URL="https://www.opensuse.org/"
# udevadm info -ap /devices/pci0000:00/0000:00:1c.0/0000:01:00.0/0000:02:00.0/0000:03:00.0/domain0/0-0/0-1/0-301
looking at device '/devices/pci0000:00/0000:00:1c.0/0000:01:00.0/0000:02:00.0/0000:03:00.0/domain0/0-0/0-1/0-301':
KERNEL=="0-301"
SUBSYSTEM=="thunderbolt"
DRIVER==""
ATTR{authorized}=="1"
ATTR{boot}=="0"
ATTR{device}=="0xb054"
ATTR{device_name}=="Dell Thunderbolt Dock"
ATTR{nvm_authenticate}=="0x0"
ATTR{nvm_version}=="16.0"
ATTR{unique_id}=="d3010000-00a2-8d18-a218-f4d4a2c2aa18"
ATTR{vendor}=="0xd4"
ATTR{vendor_name}=="Dell"
This will be important to notice in the remove rule.
# udevadm monitor --environment --udev
UDEV [36689.512928] remove /devices/pci0000:00/0000:00:1c.0/0000:01:00.0/0000:02:00.0/0000:03:00.0/domain0/0-0/0-1/0-301 (thunderbolt)
ACTION=remove
DEVPATH=/devices/pci0000:00/0000:00:1c.0/0000:01:00.0/0000:02:00.0/0000:03:00.0/domain0/0-0/0-1/0-301
DEVTYPE=thunderbolt_device
SEQNUM=12594
SUBSYSTEM=thunderbolt
USEC_INITIALIZED=36689419102
Using at (enable atd through systemctl)
ACTION=="add", SUBSYSTEM=="thunderbolt", ATTR{vendor}=="0xd4", ATTR{device}=="0xb054", RUN="/usr/bin/at -M -f /home/fblaise/bin/udev_plug_dock.sh now"
ACTION=="remove", SUBSYSTEM=="thunderbolt", ENV{DEVPATH}=="/devices/pci0000:00/0000:00:1c.0/0000:01:00.0/0000:02:00.0/0000:03:00.0/domain0/0-0/0-1/0-301", RUN="/usr/bin/at -M -f /home/fblaise/bin/udev_unplug_dock.sh now"
# https://www.linuxquestions.org/questions/linux-desktop-74/udev-not-doing-remove-rules-841733/
# no access to ATTR upon remove and not much ENV variables available, so cannot re-use the same.
udevadm test --action=add /devices/pci0000:00/0000:00:1c.0/0000:01:00.0/0000:02:00.0/0000:03:00.0/domain0/0-0/0-1/0-301
udevadm test --action=remove /devices/pci0000:00/0000:00:1c.0/0000:01:00.0/0000:02:00.0/0000:03:00.0/domain0/0-0/0-1/0-301
# udevadm control --reload
Rules should be reloaded via inotify.
export DISPLAY=:0export XAUTHORITY=/home/username/.Xauthority