JSON Wmctrl
This is a partial reimplementation of wmctrl, the linux tool to interact with windows, but supports JSON output for more subtle control.
At the moment, this only supports window listing because that is all I needed. The syntax is not compatible with the original wmctrl.
Motivation
I use the wmctrl tool to raise windows like so [[wmctrl]] -x -a "Firefox". However, this does not work well if you have multiple windows. I wanted to use wmctrl to get all firefox windows and toggle between them. But the output from wmctrl was difficult to parse.
Usage
json-wmctrl will output all top level windows in JSON.
You can search by class name with json-wmctrl --class "Firefox" for example (this support regular expressions).
There is a flag --next-unfocused which will output just the next unfocused window.
This can be used together with wmctrl -i -a and jq to cycle focus through windows.
Alternatives and prior work
This uses the Xlib python library, which you could use directly. See this stackoverflow post on the topic.
This C++ command line tool by DarkMaguz implements this feature. But it is not easy to install like pip programs.
About me
I am @readwithai. I make tools for reading and agency sometimes in Obsidian and occassionally write about these things. I also have a side-line in small useful tools.
If any of that sounds useful, you can follow me on X. I often post about command-line hacks and tools here. You can also follow me on my blog (https://readwithai.substack.com).
Also you could read with review of note taking with Obsidian.
Metadata
Release files for json-wmctrl 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| json-wmctrl-1.0.0.tar.gz | 3.0 kB | Without provenance | Details for json-wmctrl-1.0.0.tar.gz |
Release files / json-wmctrl-1.0.0.tar.gz
| Download URL | json-wmctrl-1.0.0.tar.gz |
|---|---|
| Size | 3.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bd35f0d888ad48601c9a8a421bbdc194d6f7bafd95d13584534186f430ee0405
|
|
BLAKE2b-256 checksum How to use checksums |
b5ad05beb320e79bfa5f6a40e6b6b8c3461df00d79fec2d66200575023c33bdb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.3
|
Security for json-wmctrl 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.