Package: windowlayout
windowlayoutMinimalist package to manage a layout of windows in Python.
Currently, only windows is supported, and I've only used this on Windows 10.BackgroundI have a lot of monitor space and got tired of rearranging my windows manually.
I quickly cobbled together a tool to let me save and restore window arrangements.
You are now reading about this tool.UsageInstall with pip (pip install windowlayout) on Python 3.6 or greaterOpen your favorite programs and arrange them to your liking on your monitorSave the current layout as a starting point:python -m windowlayout saveEdit~/.windowlayout.jsonto tweak it (see below)When you want this window layout again, runpython -m windowlayout applyFor alternate layouts, specify a name aftersaveorapply.ConfigurationBy default, layout data is stored in~/.windowlayout.json.
The-f/--layout-fileargument can be used to specify another file.
The layout data has two main sections:programs, andlayouts.NOTE:Usually you will have all sorts of vauge background windows you can't identify after running save.
You should remove anything from your layout that you don't recognize.
Also, if you don't need the title or class fields to distinguish between programs, don't use them.Program ConfigurationThe"programs"json object specifies named programs that you may use in layouts.
They have the following fieldscommand: The command line string to run to start the program (required)detected_command: The command line string to look for to find an already running window of this program (if not specified,commandis used)detected_title: If specified, the window title must match this string when finding an already running instance of the windowdetected_class: If specified, the window class must match this string when finding an already running instance of the windowsuppress_start: If true (default is false if unspecified), do not attempt to start the program if a pre-existing window is not foundThedetected_commandfield exists because sometimes you need run one command to start a program but the process owning the window doesn't have the same command.
Thedetected_titleis useful when a process may have multiple windows but only one is the "real" one.
Thesuppress_startflag was added because when I start Spotify while this program is running, the Spotify UI freezes and I haven't debugged why.Layout ConfigurationThe"layouts"json object contains definitions for the available layouts you can apply.
The default layout when no layout is specified is named"default".Each layout is a json object where the property names reference a named program in the"programs"object.
If you want to have multiple windows with the same program, you need multiple entries in the"programs"object.
Normally you need this anyway so you can specify command-line arguments for the different windows.The property value is another json object specifying the left, top, bottom, and right coordinates of the window.
These coordinates are in pixels and may be negative depending on the monitor layout.
The top / left coordinates are 0, and values increase towards bottom / right.The simplest way to define a layout is to arrange the windows roughly how you want them and save the layout.
Then prune the list of programs down to what you care about and remove restrictions you don't need (likedetected_titlebeing the empty string).If you want to create a second layout and have already crafted an initial one, consider using the-fargument to specify an alternate file.
That way, all the stuff you removed the first time doesn't get added back when it is detected again.