[clug] Connecting a monitor with xrandr

Paul "TBBle" Hampson Paul.Hampson at Pobox.com
Thu Dec 31 23:29:29 MST 2009

2009/12/28 David Tulloh <david at tulloh.id.au>:
> I often use my laptop with an external monitor, which I normally rotate on
> it's side.
> This is the recipe I follow every time I plug a monitor in.  Am I missing
> something?  This seems far too complicated.
> # Fire up the second monitor
> xrandr --output VGA --auto --right-of LVDS
> # Rotate the second monitor
> xrandr -o right
> # For some reason the first monitor is disabled now, switch it back on
> xrandr --output LVDS --auto
> # Now the monitors aren't using the full area.  This fixes it all up.
> xrandr --output VGA --auto --right-of LVDS
> # After the rotate the dpi is all wonky, which affects programs like
> Mozilla.
> xrandr --dpi 98x98
> Does someone here understand X properly and can simplify this?

You can stack up your xrandr commands in one line, if that helps? I
have an alias
for when I plug or unplug the HDMI cable in my laptop:

xrandr --output LVDS --auto --output HDMI-0 --right-of LVDS --auto

> While I'm asking questions, does anyone know how to trigger a script on
> connection of a video cable?  I've found HAL events for docking station
> connection but not just plugging in a VGA line.

I was wondering about this myself recently... I didn't look though.
Maybe there's an X
event (does Xrandr support events?), or an ACPI event, that could be caught?

It might be that VGA doesn't have a triggered event when you plug it
in, as I believe the
card has to check for load presence on one of the analog pins, which
isn't done until the
next xrandr call.

Paul "TBBle" Hampson, Paul.Hampson at Pobox.com

More information about the linux mailing list