[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Running a script on monitor connect/disconnect


I am having trouble getting my multi-monitor setup running properly using the 
proprietary AMD drivers in Debian testing using XRandR. My hardware is an HP 
Compaw 615 Laptop, with a Radeon HD 3200 graphics card. I am using KDE 4.6.5. 
I want the external screen, if it is connected, to be to the right of my 
internal laptop screen, both using their native resolution. I quickly found 
out that no GUI will be of any help here...

I ended up editing the xorg.conf to force the resolution of my internal 
monitor to the native one, to prevent X.org from automatically choosing a 
lower resolution that's also supported by the external screen (since it 
defaults to cloning). I also had to increase the size of the virtual desktop. 
Finally, to get the screen setup I want, I added some commands to 
/etc/kde4/kdm/Xsetup to detect whether a monitor is connected and do the 
actual setup using xrandr. You can find both configuration files attached.

However, when I plug in the screen after logging in, (of course) I manually 
have to execute xrandr again to enable the external monitor. Is there a way to 
call a shell script on monitor connect/disconnect events where I can then set 
up everything the way I want to?

Also, I wonder if there is no better way to specify a default setup that's not 
"clone same image on all screens". I tried to add the external monitor to the 
xorg.conf (fearing trouble for the case where it is not connected), and added 
the "RightOf" option, but both monitors would still use the same (non-native) 
resolution. And I absolutely do not want to hard-code the resolution of the 
external monitor since there are several monitors I connect to, with different 

Kind regards,
Section "Device"
	Identifier    "Radeon HD 3200 Graphics"
	Driver        "fglrx"
	Option "Monitor-LVDS" "LVDS"

Section "Monitor"
	Identifier  "LVDS"
	Option "PreferredMode" "1366x768"
	Option "Primary" "true"

Section "Screen"
	Identifier "The One And Only Screen"
	Monitor "LVDS"
	Device "Radeon HD 3200 Graphics"
	SubSection "Display"
		# Necessary to make dual-view work
		Virtual 3000 3000

Attachment: Xsetup
Description: application/shellscript

Reply to: