autotiling
autotiling copied to clipboard
Script for sway and i3 to automatically switch the horizontal / vertical window split orientation
autotiling
This script uses the i3ipc-python library to switch the layout splith/splitv depending on the currently focused window dimensions. It works on both sway and i3 window managers.
Inspired by https://github.com/olemartinorg/i3-alternating-layout.
See on YouTube:
PLEASE DO READ THIS
The script does one thing: it checks the window height / width ratio, and executes
the equivalent of either swaymsg splitv or swaymsg splith. Nothing less, nothing more. Yes, it may make
stacking and tabbed layouts behave oddly. No, nothing can be done about it. If you like stacking/tabbed layouts,
you may use them on workspaces with autotiling turned off (--workspaces argument). Do not submit issues about it.
For instance, you may configure autotiling to work on odd workspaces, but not on even:
### Autostart
exec autotiling -w 1 3 5 7 9
Installation
The script has been packaged for the following distributions:
Installing manually:
- Install the
python-i3ipc>=2.0.1package (or whatever it's called in your Linux distribution); - save the
main.pyfile anywhere, rename toautotiling, make executable, move to your bin folder; - add
exec_always autotilingto the~/.config/sway/configorexec_always --no-startup-id autotilingto the~/.config/i3/configfile.
Usage
$ autotiling -h
usage: autotiling [-h] [-d] [-v] [-w [WORKSPACES ...]] [-e [EVENTS ...]]
optional arguments:
-h, --help show this help message and exit
-d, --debug print debug messages to stderr
-v, --version display version information
-w [WORKSPACES ...], --workspaces [WORKSPACES ...]
restricts autotiling to certain workspaces; example: autotiling --workspaces 8
9
-e [EVENTS ...], --events [EVENTS ...]
list of events to trigger switching split orientation; default: WINDOW MODE
Events
Changing event subscription has already been the objective of several pull request. To avoid doing this again and again,
starting from v1.6 you may specify them in the -e | --events argument. If no value given, the script will subscribe
to Event.WINDOW and Event.MODE, as if it was executed with autotiling -e WINDOW MODE. See
altdesktop/i3ipc-python`
for event enumeration.
