Skip to main content

List X windows with json output

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

json-wmctrl-1.0.0.tar.gz (3.0 kB view details)

Uploaded Source

File details

Details for the file json-wmctrl-1.0.0.tar.gz.

File metadata

  • Download URL: json-wmctrl-1.0.0.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for json-wmctrl-1.0.0.tar.gz
Algorithm Hash digest
SHA256 bd35f0d888ad48601c9a8a421bbdc194d6f7bafd95d13584534186f430ee0405
MD5 35f346a95f99b4bc0412b1af2652f9ac
BLAKE2b-256 b5ad05beb320e79bfa5f6a40e6b6b8c3461df00d79fec2d66200575023c33bdb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page