User Scripts & Dragons - udev rule and script for enabling HDMI on cable plug in

Nex - 18.08.2011, 06:26
Post subject: udev rule and script for enabling HDMI on cable plug in
Hi folks,

I am trying to creat a udev rule for my AMD Radeon HD 6310 (free xorg radeonhd driver) HDMI port to activate automatically after plugging the cable in. This is, what I have so far:


KERNEL=="card0", ACTION=="change", RUN+="/home/nex/bin/hdmi.sh"



status="$(cat /sys/class/drm/card0-HDMI-A-1/status)"

export XAUTHORITY=/home/nex/.Xauthority
export DISPLAY=:0.0

if [ "${status}" = disconnected ]
 xrandr --output LVDS --auto --output HDMI-0 --off
elif [ "${status}" = connected ]
 xrandr --output LVDS --auto --output HDMI-0 --auto --same-as LVDS

This works, at least partially (got inspired by by this).
Although this works fine if I plug the HDMI cable in, removing the cable changes nothing. I have to set resolution etc. manually. A second connecting of the cable again executes the script.

This is, what udevadm monitor says for cennecting:

udevadm monitor
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent

KERNEL[100.176249] change   /devices/pci0000:00/0000:00:01.0/drm/card0 (drm)
UDEV  [100.869104] change   /devices/pci0000:00/0000:00:01.0/drm/card0 (drm)

For disconnecting nothing happens. Any idea why the connect is recognized but not the disconnect? Any hints, where (logfile, what ever) I could have a look for solving the problem?

In addition there is the KDEDeamon (?) which starts the monitor settings window as soon as I connect or disconnect (!) the HDMI cable. So disconnecting seems to be recognized, but where and how?

Any help is appreciated!

All times are GMT - 12 Hours
Powered by PNphpBB2 © 2003-2010 The Zafenio Group