auto-turn off LCD with ext. display (what does this script actually do?)

i’ve found a script that someone has blogged…

I put the script into the Xsession.d directory so it gets started for every user on boot: /etc/X11/Xsession.d/98vgaonly and made it executable.

The actual script line is this:
xrandr -q | grep ‘VGA connected’ && xrandr --output LVDS --off --output VGA --auto
It checks if the line ‘VGA connected’ was found in xrandr’s query and then asks your X server to turn off the internal output and use the external one with automatic resolution detection.

So to automatically switch to a connected VGA during boot just execute:

echo 'xrandr -q | grep \'VGA connected\' && xrandr --output LVDS --off --output VGA --auto' | sudo tee /etc/X11/Xsession.d/98vgaonly && sudo chmod a+x /etc/X11/Xsession.d/98vgaonly

taken from Linux Tipps & More: Automatically switch to connected External Display on Boot with XRandR

i see it’s using the VGA output that xrandr -q is detecting, which is correct for my setup, but im not sure about the other bits like xsession.d and 98vgaonly.

i see what the creator has done, but im not sure on the ins/outs of what this command is actually doing. can someone clarify please…

a) it is suitable for openSUSE use (11.2 x64)?
b) will it only detect & switch during boot up, or does it detect when the external display is connected when when suse is running?
c) if A is not true, then how can it be moddified for SUSE use?

thanks for any help!

Hi,

For the b), here’s what the author say :

It would probably be possible to somehow call this script automatically when plugging in a monitor, but I’ve not figured out how. xrandr only works when called from inside the running X session in my experience.

I think it is suitable for oS 11.2, but you have to adjust it for the xrandr output.

thanks for confirming that - i was pretty sure it only detected at bootup, rather than on-the-fly, just wasnt 100%.

i’ve got round to testing the command; no go - nothing happens at all :frowning:

Did you check that the syntax suits you’re system. Maybe the arguments for the xrandr are not the correct one.

You can check this with : xrandr -q

that bit seems fine - yes i did check xrandr -q.

the issues seem to be the end of the second command with the ‘| tee …’ part. once i press enter, i get a > prompt (similar to the nslookup > prompt). i cant seem to work out why it’s doing that, unless terminal doesnt like copy&pasting…

On 2010-07-15 21:16 GMT veehexx wrote:

>
> that bit seems fine - yes i did check xrandr -q.
>
> the issues seem to be the end of the second command with the ‘| tee
> …’ part. once i press enter, i get a > prompt (similar to the
> nslookup > prompt). i cant seem to work out why it’s doing that, unless
> terminal doesnt like copy&pasting…

Incomplete/incorrect command line. You probably have a “’” too more or
less, ie, not paired, or not the correct one.


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” GM (Minas Tirith))