disp saves and restores monitor layouts for i3
Clarification in the readme.

heads

tip
browse log

clone

read-only
https://hg.sr.ht/~ser/disp
read/write
ssh://hg@hg.sr.ht/~ser/disp

#disp

#Note

disp works but is neither currently used nor maintained by me. I've been using umonitor which does the same thing, works well, and hasn't been updated in 2 years -- which is evidence that it's robust. If, for some reason, umonitor doesn't work for you and you're searching for something that does, and you come across this, and it is helpful, let me know and I may pick this up. I just have too many projects on my plate.

disp saves and restores monitor layouts.

To use, set up your displays the way you want them laid out with your usual tool (e.g., xrandr, grandr, ...) and then call it with -s to save the layout. Then, whenever you want to load the layout, call disp with -l.

disp can be run in daemon mode with -d to have disp listen for display changes and automatically restore the layout.

When it works, it gets close to what OSX and Windows do by restoring monitory layouts. It doesn't (yet) auto-save layouts; after reconfiguring, you have to call disp -s.

#Examples

disp -h prints usage instructions

disp -p prints current the currently configured layout; this is what would get saved with the -s command.

disp -s saves the current layout. Configurations are stored in $XDG_CONFIG_HOME/disp/config as a JSON file.

disp -l restores a layout from the config file. Only exact matches are restored; this means exactly the same monitors, and the same combination of connected monitors, will be restored from the config file. For example, if one monitor is turned off, the layout will not match any configuration in the config file, and no layout will be performed. However, this means that multiple layouts can be managed using the same monitors by changing the number of connected monitors.

disp -d runs disp in daemon mode, where it will watch for and react to changes. This is the main reason for disp; to automatically restore layouts when a laptop is docked, similar to how OSX and Windows do.

disp -k kill running daemon; the PID file is stored in a file called disp.pid in the xdg-user-dir RUNTIME directory.

With no args, prints the known displays.

#Caveats

This is a simple script, built around my system. At the time of this writing, it's been tested nowhere else. There are no guarantees that it will work on your system; in fact, I'm going to guess that it doesn't. However, if it doesn't, shoot me a ticket with as much information as you can, and I'll see what I can do. Or, if you fix it, send me a pull request and I'll merge it.

#Alternatives

I wrote this because every tool I'd seen so far failed in one way or another. One important way is when the manager depends on the display name to match monitors. This is fragile and will fail, because X will give different names to the same monitors depending on, I don't know, the phase of the moon or some crap. My monitors frequently vacillate between DP1-n (DP1-1, DP1-2) and DP2-n (DP2-1, DP2-2). The correct way to do this is use a monitor attribute gathered from EDID, if it's available -- which is usually is, unless you're connecting via VGA.

umonitor

: Pros:

* Uses EDID for monitor IDs
* Has a command to record a configuration based on current layout
* Can run in daemon mode and monitor for changes

Cons:
* None, really.  Well, it's Python, and daemons shouldn't be written in interpreted languages.

Use this instead of `disp`

grobi

: Pros:

* Written in Go, so nice stand-alone binary that's immune to breakage due to interpreter upgrades.
	
Cons:
* Configuration indexed on display names, so it doesn't work for me.
* Configuration has to be written by hand

mons

: It's a tool that can be used to arrange displays more easily than with xrandr; it is not a hotplug event driven tool to automatically manage layouts.

srandrd

: It's a tool around which hotplug event handling tools could be built; it's not a solution (to this problem) in itself.