5 ms·
I run 3 displays across 2 video adapters. Getting them all to work as I want (one of them is generally powered down, but not disconnected) was a struggle, but n
by PaulDavisThe1st 5y ago
I run 3 displays across 2 video adapters. Getting them all to work as I want (one of them is generally powered down, but not disconnected) was a struggle, but now works flawlessly and I tend to forget about the work involved.
The key things I needed to find out:
1. figuring out how to run a script when a display was connected or disconnected. This needed to be in a udev .rules file somewhere
ACTION=="change", SUBSYSTEM=="drm", ENV{HOTPLUG}=="1", RUN+="/usr/local/bin/monitor-hotplug.sh"
2. how to enumerate all possible video display names:
DEVICES=$(find /sys/class/drm/*/status)
3. Writing the rest of the script.
The last step is mostly left as an exercise for the reader. There are some good examples online; I'll put my current version here https://pastebin.com/V5yGgCbh https://pastebin.com/V5yGgCbh for a couple of weeks.
- Lhiw 5y agoYou should checkout srandrd, it lets you run a simple bash script when monitor changes happen. It includes some Env vars so you can figure out what happened. Been a while but I had real issues using udev rules as they created timing problems or something like that. https://github.com/jceb/srandrd https://github.com/jceb/srandrd
- tdeck 5y agoIt's pretty telling how the top two solutions here for this common problem involve writing custom scripts. I love scripting at least as much as the next guy, but this seems like something that should be easily configurable out of the box without a text editor.
- PaulDavisThe1st 5y agoIf your setup is relatively static, then there are GUI tools that will work just fine. But if you have displays coming and going in different orders, it's quite a big ask to have a GUI tool that can define the sort of conditional logic that is required to get things right. This is precisely what I've got in my case.
- AtlasBarfed 5y agoMy mac remembers the displays and where I placed them relative to my laptop, even if they are all the same resolution over HDMI. Why can't linux do this? I'm assuming displays have detectable ids of some sort?
- ccouzens 5y ago> I'm assuming displays have detectable ids of some sort? Yes, the EDID information uniquely identifies a screen. https://en.m.wikipedia.org/wiki/Extended_Display_Identification_Data https://en.m.wikipedia.org/wiki/Extended_Display_Identificat... > Why can't linux do this? It does for me (fedora, gnome, wayland). Other stacks are more work. I was put off using Sway as my desktop, because screen resolutions and layouts was manual.
- mixedCase 5y agoKanshi is the default solution when you need dynamic monitor management in Sway: https://sr.ht/~emersion/kanshi/ https://sr.ht/~emersion/kanshi/
- PaulDavisThe1st 5y agoIt gets better. One of my ASUS monitors has a defect (it kicked in after several years of use) where it no longer provides EDID information. I believe that on windows and macOS this would effectively be the end-of-life for the monitor, which is a shame since in every other way it is still 100% functional. On Linux, I was able to tell the kernel to use a file for the EDID information, and created the file using the other (identical) monitor. Very much a corner case, but also another perfectly good monitor kept out of a landfill.
- paulfurtado 5y agoWindows may actually let you override the EDID info, it's been a while since I used windows but I think it lets you do it in device manager... from the era when displays came with drivers on a cdrom. There are also EDID cloner/emulator hardware solutions that you plug in inline on the display cable.
- wmf 5y agoMost of the behavior the OP wants should just be the default; it shouldn't even require configuration.
- Lhiw 5y agoTiling window managers don't have GUI solutions to a lot of things. Part of the territory. I also have far less complications as a result. My desktop hasn't changed in close to 10 years.
- PaulDavisThe1st 5y agoNice! Thanks a lot for that.