3 releases

0.0.45 Mar 31, 2022
0.0.40 Dec 18, 2021
0.0.39 Dec 18, 2021

#952 in GUI

Download history 3/week @ 2024-02-15 26/week @ 2024-02-22 21/week @ 2024-02-29 3/week @ 2024-03-07 2/week @ 2024-03-14

53 downloads per month
Used in wmctl




license-badge crates.io Minimum rustc

Rust X11 automation

libwmctl implements the Extended Window Manager Hints (EWMH) specification as a way to work along side EWMH compatible window managers as a companion. libwmctl provides the ability to precisely define how windows should be shaped and placed and can fill in gaps for window managers lacking some shaping or placement features. libwmctl exposes X11 details in a simple consumable way opening the door to window manipulation beyond what your favorite EWMH window manager provides.


This minimum rustc requirement is driven by the tracing_subscriber requirements

Shape window

Shape the active window using the pre-defined WinShape::Small shape which is a quarter of the screen.

use libwmctl::prelude::*;

fn main() {

Move window

Move the active window to the bottom left corner of the screen using the pre-defined WinPosition::BottomLeft position.

use libwmctl::prelude::*;

fn main() {

Place window

Combine the shape and move into a single command by placing the window. First the window is shaped using the pre-defined WinShap::Small shape then it is moved to the bottom left using the pre-defined WinPosition:BottomLeft position in a single operation.

use libwmctl::prelude::*;

fn main() {

Window Manager info

use libwmctl::prelude::*;

fn main() {
    let wmctl = WmCtl::connect().unwrap();
    let (_, wm_name) = wmctl.winmgr().unwrap();
    let win = wmctl.active_win().unwrap();
    println!("X11 Information");
    println!("Window Manager:    {}", wm_name);
    println!("Composite Manager: {}", wmctl.composite_manager().unwrap());
    println!("Root Window:       {}", wmctl.root());
    println!("Work area:         {}x{}", wmctl.work_width(), wmctl.work_height());
    println!("Screen Size:       {}x{}", wmctl.width(), wmctl.height());
    println!("Desktops:          {}", wmctl.desktops().unwrap());
    println!("Active Window");
    println!("{:-<120}", "");

    println!("{:<8} {:<3} {:<6} {:<5} {:<5} {:<4} {:<4} {:<8} {:<7} {:<18} {:<18} {}", "ID", "DSK", "PID", "X", "Y", "W", "H", "BORDERS", "TYPE", "STATE", "CLASS", "NAME");

    let pid = wmctl.win_pid(win).unwrap_or(-1);
    let desktop = wmctl.win_desktop(win).unwrap_or(-1);
    let typ = wmctl.win_type(win).unwrap_or(WinType::Invalid);
    let states = wmctl.win_state(win).unwrap_or(vec![WinState::Invalid]);
    let (x, y, w, h) = wmctl.win_geometry(win).unwrap_or((0,0,0,0));
    let (l, r, t, b) = wmctl.win_borders(win).unwrap_or((0, 0, 0, 0));
    let class = wmctl.win_class(win).unwrap_or("".to_owned());
    let name = wmctl.win_name(win).unwrap_or("".to_owned());
    println!("{:<8} {:<3} {:<6} {:<5} {:<5} {:<4} {:<4} {:<8} {:<7} {:<18} {:<18} {}",
        format!("{:0>8}", win), format!("{:>2}", desktop), pid,
        format!("{:<4}", x), format!("{:<4}", y), format!("{:<4}", w), format!("{:<4}", h), 
        format!("{},{},{},{}", l, r, t, b),
        typ.to_string(), format!("{:?}", states), class, name);


Pull requests are always welcome. However understand that they will be evaluated purely on whether or not the change fits with my goals/ideals for the project.


Enable the git hooks to have automatic version increments

cd ~/Projects/wmctl
git config core.hooksPath .githooks


This project is licensed under either of:


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.




~62K SLoC