#window #manager #wm #linux #wmctrl

wmctrl

A wrapper for the command line tool wmctrl written in Rust

6 releases

0.1.8 Jan 26, 2021
0.1.7 Feb 20, 2020
0.1.6 Jan 31, 2020

#218 in Operating systems

Download history 20/week @ 2023-02-10 27/week @ 2023-02-17 4/week @ 2023-02-24 12/week @ 2023-03-03 11/week @ 2023-03-10 12/week @ 2023-03-17 15/week @ 2023-03-24 6/week @ 2023-03-31 13/week @ 2023-04-07 9/week @ 2023-04-14 9/week @ 2023-04-21 19/week @ 2023-04-28 21/week @ 2023-05-05 11/week @ 2023-05-12 6/week @ 2023-05-19 17/week @ 2023-05-26

56 downloads per month

GPL-3.0-or-later

18KB
288 lines

Wmctrl Wrapper

A wrapper for the command line tool wmctrl written in Rust

Dependencies

wmctrl needs to be installed:

# Ubuntu
sudo apt install wmctrl

# Arch Linux
sudo pacman -S wmctrl

# Fedora 
dnf install -y wmctrl

# You get the idea

Usage

Add wmctrl to your dependencies in your Cargo.toml:

[dependencies]
wmctrl = "0.1.7"

If you want the latest build use the GitHub repository as your uplink:

[dependencies]
wmctrl = { git = "https://github.com/Treborium/rust-wmctrl" }

Examples

Please refer to the documentation for detailed information.

If you want to copy & paste the examples below you need to use the following import statement:

use wmctrl::{Self, Window};

Find a window based on the title:

let windows = wmctrl::get_windows();
let firefox = wmctrl::utils::find_window_by_title(&windows, "Firefox").unwrap();
println!("{}", firefox);

Resize and move a window to the specified coordinates:

let mut windows = wmctrl::get_windows();
let win = &mut windows[0];
// This will move the window to the top left corner and resize it to 960x540
win.transform(wmctrl::Transformation::new(0, 0, 960, 540));

Close the window gracefully:

// We need to move the window out of the vector so there is no reference left
let win: Window = wmctrl::get_windows().remove(0);
win.close();

Make the window fullscreen:

let windows = wmctrl::get_windows();
let win = &windows[0];
// Make the window fullscreen
win.change_state(wmctrl::State::new(wmctrl::Action::Add, wmctrl::Property::Fullscreen));

Dependencies

~1–1.4MB
~38K SLoC