You are not logged in.

#1 2012-03-16 05:13:15

Cerales
Member
Registered: 2011-01-04
Posts: 32

Configure X11 / xorg to automatically adapt to new monitor plugged in?

I take my laptop daily between work and home, and I want to be able to resume it from sleep and plug in my DisplayPort monitor and have it go into dual-screen.

At the moment, I have to run arandr and configure it manually. Doesn't take too long, but it'd certainly be nice if I could configure it to Just Work.

Can someone give me some pointers here? I don't want some gnome magic or whatever, just some understand of what the hooks are that I could script, how this is done conventionally, etc. If at all possible I would really, really like not to have to edit files in /etc/X11/xorg.conf.d/.

Offline

#2 2012-03-17 14:06:40

nomorewindows
Member
Registered: 2010-04-03
Posts: 3,548

Re: Configure X11 / xorg to automatically adapt to new monitor plugged in?

That's pretty much the way you do it, with xrandr.  If you are using gnome it will do this automatically.


I may have to CONSOLE you about your usage of ridiculously easy graphical interfaces...
Look ma, no mouse.

Offline

#3 2012-03-19 01:12:17

Cerales
Member
Registered: 2011-01-04
Posts: 32

Re: Configure X11 / xorg to automatically adapt to new monitor plugged in?

So if I want to do it without gnome, I need to set up some scripts that will detect the system event of a monitor being plugged in and unplugged and call xrandr with the script generated by arandr?

Offline

#4 2012-03-19 22:54:57

nomorewindows
Member
Registered: 2010-04-03
Posts: 3,548

Re: Configure X11 / xorg to automatically adapt to new monitor plugged in?

I'm not exactly sure what gnome uses to do this, but some information is passed on by EDID, which identifies the monitor plugged into it.  Gnome also notices when the monitor becomes unplugged, which your script would probably use some similar function to detect the monitor.

Last edited by nomorewindows (2012-03-19 22:56:56)


I may have to CONSOLE you about your usage of ridiculously easy graphical interfaces...
Look ma, no mouse.

Offline

#5 2012-03-20 00:06:23

ConnorBehan
Package Maintainer (PM)
From: Long Island NY
Registered: 2007-07-05
Posts: 1,359
Website

Re: Configure X11 / xorg to automatically adapt to new monitor plugged in?

Can't you just use xrandr -q to tell if a monitor is connected?


6EA3 F3F3 B908 2632 A9CB E931 D53A 0445 B47A 0DAB
Great things come in tar.xz packages.

Offline

#6 2012-03-20 00:24:11

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,557
Website

Re: Configure X11 / xorg to automatically adapt to new monitor plugged in?

arandr is just a gui front end for xrandr.

You could figure out the xrandr line yourself, or use arandr *once* and select the menu option (I forget where it is, but there aren't many menus) that will show you the xrandr command it executes.

You can then put this in a script, or even bind it to a keypress.  Or if you want it really "automagic" you could try having it run from a udev rule that responds to plugging of the monitor.  I believe such udev rules are possible, but I can't verify it.

In anycase, the keybind to an xrandr line is simple enough.  I have the external monitor "media" button on my netbook mapped to a script that will detect and set the best resolution on the attached monitor/projector and put it as an "extended desktop" wwhile my internal monitor stays at it's default.

So, again, generate the command from arandr, or just read up on xrandr's man page, then script it or bind it to a key.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#7 2012-03-20 01:36:04

ConnorBehan
Package Maintainer (PM)
From: Long Island NY
Registered: 2007-07-05
Posts: 1,359
Website

Re: Configure X11 / xorg to automatically adapt to new monitor plugged in?

Neat. It looks like they did that here: http://stackoverflow.com/questions/5469 … l-graphics

Thanks to Trilby for catching this. I clicked the back button a bunch of times and saw one of my posts and one of his posts and assumed I was in the right place.


6EA3 F3F3 B908 2632 A9CB E931 D53A 0445 B47A 0DAB
Great things come in tar.xz packages.

Offline

Board footer

Powered by FluxBB