You are not logged in.
I have the following udev rule and script:
$ cat /etc/udev/rules.d/20-hdmi.rules
ACTION=="change", SUBSYSTEM=="drm", ENV{DISPLAY}=":0", ENV{XAUTHORITY}="/home/jamie/.Xauthority", RUN+="/usr/bin/hdmi-plugged"
$ cat /usr/bin/hdmi-plugged
#!/bin/bash
exec >/home/jamie/udev.out 2>&1
export XAUTHORITY=/home/jamie/.Xauthority
export DISPLAY=:0
#sleep 5
/usr/bin/xrandr --output HDMI1 --auto --output eDP1 --auto --above HDMI1
The script runs when I plug my HDMI monitor in and out of my laptop, but xrandr does the opposite of what I think it should, ie, when I unplug the HDMI monitor the script turns the HDMI1 output on and when I plug the monitor in the script turns the output off. If I run the script manually it work as expected. Adding the sleep line doesn't help. I have also tried checking for the connection status and specifically setting the output on/off as appropriate, but with the same effect. It's as if the script always runs before xrandr is updated. Is there anything I can do to get the udev rule/script to run correctly?
Last edited by JamieKitson (2016-09-17 13:10:53)
Offline
This odd workaround (ie, running xrandr before and after the sleep) from xrasengan seems to solve the issue.
Last edited by JamieKitson (2016-09-17 13:13:02)
Offline