Live data from Hacker News

Show HN: Change screen layout when connecting/disconnecting monitors

github.com

11–20 of 33 posts

Re: Show HN: Change screen layout when connecting/disconnecting monitors

#11
post #9

I have a little python script to do a similar 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 sa…

I used a bash script to do this, until I got a laptop that has only a mini-display port. Now I don't/can't connect to anything :(

Re: Show HN: Change screen layout when connecting/disconnecting monitors

#12
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.

Re: Show HN: Change screen layout when connecting/disconnecting monitors

#13
post #11
post #9

I have a little python script to do a similar 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 sa…

I used a bash script to do this, until I got a laptop that has only a mini-display port. Now I don't/can't connect to anything :(

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.

Re: Show HN: Change screen layout when connecting/disconnecting monitors

#14
post #8
post #2

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.

Gnome doesn't do this. Without fail, every time, it puts the dock on the wrong external display. Every. Time.

feel your frustration , I just never take mine of the dock cause i can't be arsed anymore.

Re: Show HN: Change screen layout when connecting/disconnecting monitors

#16
post #2

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.

This issue is the very reason I use KDE Plasma, I never came across another DE that handled multi-monitors correctly.

Re: Show HN: Change screen layout when connecting/disconnecting monitors

#18
post #10

For reference, there's also autorandr [1] and x-on-resize [2]. [1] https://github.com/wertarbyte/autorandr [2] http://keithp.com/blogs/x-on-resize/

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.

Re: Show HN: Change screen layout when connecting/disconnecting monitors

#20
post #10

For reference, there's also autorandr [1] and x-on-resize [2]. [1] https://github.com/wertarbyte/autorandr [2] http://keithp.com/blogs/x-on-resize/

This is a good documentation for autorandr: https://help.ubuntu.com/community/DynamicMultiMonitor
Post reply on HN