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

External monitor autoconfiguration

Tags: None
(comma "," separated)
elcuco
Registered Member
Posts
20
Karma
0

External monitor autoconfiguration

Sat May 08, 2010 9:08 am
I have a monitor, which I want to user as an external monitor on my laptop. What I want is:

When I connect it, the LVDS should be automatically "killed" and the external monitor should be connected at it's max resolution (it's the default). Needless to say - I want to get the LVDS back when I unplug the monitor.

Is this possible in KDE44? if not, does anyone know how to script this this? Again, I want this to be done automatically (hey, win7 does it! linux should be able to do it as well!)
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Whilst I am not sure if KDE offers the ability to turn the LVDS panel off and on depending on if a monitor is connected, I do know that the "xrandr" tool will be able to help you do these tasks.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
elcuco
Registered Member
Posts
20
Karma
0
ok, this means writing a shell script. OK.

Do you konw which "event" gets fired when I connect a monitor? How can I run a script when this happens? (does hal send a dbus event? )
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
I gather that HAL ( or udev ) must send an event, since storage media appears immediately upon connection also and hardware appearing is a universal mechanism.

Unfortunately I don't know which one, however whichever Solid listens to is likely the appropriate one ( although you will need to filter by UDI to ensure that you only trigger for this monitor )

Alternately, you could use KHotKeys to setup a hotkey to alternate between modes ( probably simpler and less prone to failure also )


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
timrichardson
Registered Member
Posts
15
Karma
0
OS
Last night I plugged in a old laptop with kde 4.4.3 to an external monitor. The laptop has intel video (my main laptop has nvidia).
To my surprise, after connection ... "KDE Daemon has detected that an external monitor has been connected" (or something like that). I was then taken to the multiple displays settings.

This never happens on my nvidia laptop, running identical software (both use sidux).

By the way, I have a script which I run on my main laptop. I have it mapped to a key. It toggles the external monitor on and off. It probably only works with exactly my configuration, and it is nvidia specific so it's way off topic, but it may help someone. Obviously I have the correct modes already setup.

Code: Select all
#!/bin/bash
nv-control-dpy --print-current-metamode | grep "id=100"
if [ $? -ne 0 ]
then
   nv-control-dpy --probe-dpys
   nv-control-dpy --build-modepool
   #nv-control-dpy --get-associated-dpys
   nv-control-dpy --set-associated-dpys 0x00010001
   nv-control-dpy --add-metamode 'CRT-0: nvidia-auto-select,DFP-0: nvidia-auto-select'
   xrandr -s 3200x1080@100

else
   xrandr -s 1280x800@50
fi

User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
This is because the Intel drivers support the RandR specification fully, whilst the NVidia ones do not support it properly.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
Thailandian
Registered Member
Posts
30
Karma
1
OS
I just happened to see this - hope it's not too late.

Here is a script that I put in my .kde4/env directory so it fires off before KDE loads. The if statement detects whether there is an external monitor plugged in. I have an Acer "emachine" laptop, with an LG external monitor, and this works well for me.
Code: Select all
#!/bin/bash
myvar="$(xrandr -q)"
if [[ $myvar == *"VGA connected"* ]]
then
  xrandr --output VGA --auto;
  xrandr --output LVDS --auto;
  xrandr --output LVDS --off;
else
  xrandr --output LVDS --auto;
fi
Line 4 of this seems redundant, turning the LVDS on, then turning it off immediately, but without it, my mouse pointer kept disappearing. Not sure if that is peculiar to my system, or a bug somewhere.

I also have various scripts for changing monitor configs on the fly. This is for Laptop monitor only:
Code: Select all
#!/bin/bash
  xrandr --output LVDS --auto;
  xrandr --output VGA --off;

And this for VGA only:
Code: Select all
#!/bin/bash
myvar="$(xrandr -q)"
if [[ $myvar == *"VGA connected"* ]]
then
  xrandr --output VGA --auto;
  xrandr --output LVDS --off;
fi
which is the same as the autorun script without the else statement.

I also have scripts for Left Xinerama:
Code: Select all
#!/bin/bash
myvar="$(xrandr -q)"
if [[ $myvar == *"VGA connected"* ]]
then
  xrandr --output LVDS --auto --left-of VGA;
fi

and Right Cinerama:
Code: Select all
#!/bin/bash
myvar="$(xrandr -q)"
if [[ $myvar == *"VGA connected"* ]]
then
  xrandr --output LVDS --auto --right-of VGA;
fi

I put all these in a folderview folder and keep that on one of my virtual desktops. The only one I have set to a hotkey is the one for Laptop monitor only, just in case there is a blackout, so I can turn my laptop monitor back on without rebooting.

Hope this helps someone.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
@Thailandian: Some people will definitely find that helpful. Perhaps you could post it in Tutorials & Tips so that it can be found more easily?


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


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]