May I ask what desktop environment you use, and what you usually use this for?
I ask because a good DE should remember the settings pertaining to each monitor configuration (display positions of course, but also things like panels placed in secondary monitors). I've been using Plasma (KDE) for about a year and it handles this reasonably well.
Well, call it a "window manager" then, it still should handle this. But that's just my opinion of the responsibilities of WMs/DEs/whatever you call them, and I understand that some don't.
I agree that good software should do this but unfortunately multi-monitor configuration software isn't always very good. My Ubuntu 15.10 system with Unity desktop decides to move the taskbar/dock thing to the other monitor every time I turn the other monitor on in the morning. There is nothing in the Screen Display GUI that seems to allow me to stop this from happening. Out of frustration I've resorted to running the xrandr command a few times (once is sometimes not enough!) to fix it each time. This tool would at least automate the task for me and seems useful.
My laptop running i3 is often moved between a dock on my desk and used as a regular laptop, I have to say I've been looking to write something like this but it fell by the wayside. Very useful IMO
I use dwm on my laptop, and I have 2 external monitors.
Every morning I had to make an xrandr call when I plugged them, and another one at the end of the day when I unplugged them to make my window manager aware of my screen layout.
This remembers the randr state that's associated with plugged in displays by their EDID and the ACPI lid switch. When you change the randr state, it remembers it, and when you change what displays are connected or open the laptop lid, it loads a previously remembered state if there is one. The state saving and loading is done by arandr, which handles the resolution, position, and choice of primary output.
Why? you would've needed a cable anyway, so not owning the right one is no excuse, (m)DP can connect to pretty much anything using cheap _passive_ adapter cables.
I am not sure if I just overlooked something, but autorandr doesn't seem to stay in the background and wait for a change but needs to be called manually, is that correct? While saving profiles can be useful if you do that a lot, that task is easily solved by writing the xrandr command used into a shellscript.
x-on-resize looks like a good alternative to xoutputd though. It's probably worth to take a closer look at it and use the one whose code is simpler and easier to read.
This is exactly what I needed, gonna put it in my window manager startup script. I already wrote a dock and undock script for my laptop a while ago, which I still had to run manually, so this is the perfect addition to that script.
Though I had some problems compiling it. For others who want to try it: On some systems (gentoo here) flex replaces lex and you need to use -lfl to link it, even though lex seems to be ususally a symlink to flex, there is no symlink for the libraries. Also on some distributions yacc doesn't seem to come with liby anymore, just remove the -ly from cflags.
TL;DR: Replace "LDADD+= -ll -ly -lX11 -lXrandr" with "LDADD+= -lfl -lX11 -lXrandr" to make it compile on Gentoo. Make sure yacc and flex are emerged.
"xoutputd is a daemon that monitors the connection state of outputs and then executes commands based on defined rules."
I'm not aware of anything built in to OS X that allows you to execute scripts to perform custom actions when displays are connected/disconnected. OS X just tries to replicate the last layout you had.
* Plugged into your desk monitor? You can have Slate hide Steam and put MacVim & iTerm side by side.
* Plugged into your TV? You can have Slate run a script to make sure your Plex server is up and then full-screen your browser.
* Etc.
32 comments
[ 5.8 ms ] story [ 26.6 ms ] threadI ask because a good DE should remember the settings pertaining to each monitor configuration (display positions of course, but also things like panels placed in secondary monitors). I've been using Plasma (KDE) for about a year and it handles this reasonably well.
Every morning I had to make an xrandr call when I plugged them, and another one at the end of the day when I unplugged them to make my window manager aware of my screen layout.
I was tired so I automated the thing.
https://github.com/larkery/nix-session/blob/master/scripts/d...
This remembers the randr state that's associated with plugged in displays by their EDID and the ACPI lid switch. When you change the randr state, it remembers it, and when you change what displays are connected or open the laptop lid, it loads a previously remembered state if there is one. The state saving and loading is done by arandr, which handles the resolution, position, and choice of primary output.
[1] https://github.com/wertarbyte/autorandr
[2] http://keithp.com/blogs/x-on-resize/
x-on-resize looks like a good alternative to xoutputd though. It's probably worth to take a closer look at it and use the one whose code is simpler and easier to read.
TL;DR: Replace "LDADD+= -ll -ly -lX11 -lXrandr" with "LDADD+= -lfl -lX11 -lXrandr" to make it compile on Gentoo. Make sure yacc and flex are emerged.
I'm not aware of anything built in to OS X that allows you to execute scripts to perform custom actions when displays are connected/disconnected. OS X just tries to replicate the last layout you had.
* Plugged into your desk monitor? You can have Slate hide Steam and put MacVim & iTerm side by side. * Plugged into your TV? You can have Slate run a script to make sure your Plex server is up and then full-screen your browser. * Etc.
https://github.com/rndstr/dotfiles/blob/master/bin/monitor-h...