A simple Linux CLI tool and D-Bus service to provide real-time information about the current active window (focused window) or pointer window (under the mouse cursor) on Wayland and X11.
wctx
consists of two components:
- A userspace daemon that interfaces with the desktop environment
- A CLI client for querying window details from the daemon in various formats
- X11
- KDE 6
- GNOME 45+
See issues for status of support for other desktop environments.
A wctx package is available for Arch Linux in the AUR:
yay -S wctx
The easiest way to build and install wctx is with the provided install script. Make sure you already have rust
and cargo
installed.
git clone https://github.com/slightlyfaulty/wctx
cd wctx
sh install.sh
This will:
- Build the binary using cargo
- Install it to
/usr/bin/wctx
- Install the systemd service file to
/usr/lib/systemd/user/wctx.service
- Optionally enable and start the daemon service
If you prefer to install it yourself:
# Build the binary
cargo build --release
# Copy the binary to a location in your PATH
sudo cp target/release/wctx /usr/bin/
# Copy the systemd service file
sudo cp wctx.service /usr/lib/systemd/user/
# Enable and start the service
systemctl --user enable --now wctx
wctx <CONTEXT> [PROPERTY] [OPTIONS]
Query active window information in JSON format:
wctx active -f json
Query a specific property of the pointer window:
wctx pointer title
Monitor the pointer window:
wctx pointer --watch
active
: Currently focused windowpointer
: Window under the mouse cursor
Type | Example Value | |
---|---|---|
id | string |
182452228 |
name | string |
google-chrome |
class | string |
google-chrome |
pid | integer |
152479 |
title | string |
Google - Google Chrome |
type | window type |
NORMAL |
role | string |
browser |
state | window state |
MAXIMIZED |
display | string |
DisplayPort-1 |
Note that some property values will differ between desktop environments.
Use the -f
or --format
option to specify the output format:
flat
(default)dict
json
toml
csv
Example:
wctx pointer -f dict
The daemon should typically be managed through systemd:
systemctl --user enable --now wctx
But you can also run it manually:
wctx daemon
# or specify the window provider explicitly
wctx daemon --provider kwin
Contributions are welcome! Please feel free to submit bug reports or pull requests.