How to swallow clients in i3 with i3-swallow
A neat feature with the tiling window manager dwm is the fact that it can swallow clients. This means that when you, for an example open a video with mpv in the terminal (or via Ranger), you can automatically replace that client with the video. This helps you save a lot of valuable space on your desktop.
This feature is not available in i3 by default, but thanks to an addon called i3-swallow and the Python library i3ipc-python, it’s possible to have this in i3 as well.
Installation
i3-swallow
The installation is pretty easy, you just have to download the source code for i3-swallow, preferably using git:
$ git clone https://github.com/jamesofarrell/i3-swallow
Then place the script in your $PATH. I use the folder ~/local/bin/
myself:
$ ln -s ~/src/git/i3-swallow/swallow.py ~/.local/bin/
i3ipc-python
This package is availbable via pip:
$ pip install --user i3ipc
I prefer to keep as much packages as possible via Gentoo’s own package manager, so I made an ebuild for it called dev-python/i3ipc
:
EAPI=7
PYTHON_COMPAT=( python3_{7..9} )
inherit distutils-r1
DESCRIPTION="An improved Python library to control i3wm and sway."
HOMEPAGE="https://github.com/altdesktop/i3ipc-python"
SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
LICENSE="BSD"
SLOT="0"
KEYWORDS="amd64"
RDEPEND="dev-python/python-xlib"
DEPEND="${DEPEND}"
Usage
You can now use the script like this:
$ swallow.py mpv <file>