This forum has been archived. All content is frozen. Please use KDE Discuss instead.

udev rule and script for enabling HDMI on cable plug in

Tags: None
(comma "," separated)
Sockenmeister
Registered Member
Posts
7
Karma
0
Hi folks,

actually it is not exactly a problem with KDE but maybe you can help me (see especially last part of my post)

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:

Code: Select all
/etc/udev/rules.d/hdmi.rules

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



Code: Select all
/home/sockenmeister/bin/hdmi.sh

#!/bin/sh

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

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

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


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 connecting:

Code: Select all
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?

Here we come to the part, were KDE comes into play: as soon as I connect or disconnect (!) the HDMI cable the monitor settings window pops up. So disconnecting seems to be recognized, but where and how? How does KDE do it?

Just in case this is important: I am running Debian Sid/aptosid with KDE 4.6.5

Any help is appreciated!

Thank you!

cu


Sockenmeister, proud to be a member of KDE forums since 2008-Nov.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Have you checked to see if the kernel sends out any other form of notification indicating that the cable has been disconnected?


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
Sockenmeister
Registered Member
Posts
7
Karma
0
Hi,

that is more or less my question. Where or how can i do that? How does KDE do it?

Thank you for your answer.

cu


Sockenmeister, proud to be a member of KDE forums since 2008-Nov.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
With KDE 4.6 and later, KDE uses UDev to recieve notifications about device changes. In KDE 4.5 and earlier, HAL is used.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], ourcraft