Skip to main content

==== EWMH ====

EWMH (Extended Window Manager Hints) can be used to retrieve and set information about windows on Linux systems. Is does this by calling and parsing the output from programs like wmctrl.

Example

from subprocess import Popen
from ruamel.ewmh import ExtendedWindowManagerHints as EWMH
Popen(['xclock', '-name', 'test_xclock'])
# there can be more than one window matching the title
# therfore .by_title() returns a list
clk = EWMH().by_title('test_xclock')[0]
clk.resize_and_move(200, 200, 300, 600)

Why not use the wmctrl package?

Before writing this library I tried Antonio Cuni’s wmctrl package. That library looks to be abandoned (at least from April 2013 until Oct 2014).

I started ewmh because I encountered performance problems and irregular exceptions that I could not, initially fix. When I noticed that these problems were a result of design decisions, were associated with features I did not need (e.g. retrieving WM_CLASS), and because I needed something more minimal, but working, I started from scratch.

  • wmctrl output information did not get cached and getting the information was horrible slow in the first place. If your machine has M windows open and you wanted the state for N of those windows, this caused a total of N * (M+1) invocations of external programs through commands.getoutput. With 200+ open windows on my system, getting information took several seconds for each window that I was interested in.

  • commands.getoutput() is used, but that has been deprecated since 2008, should have used subprocess.checkout_output() instead.

  • the output of getoutput() was not checked for errors.

  • os.system() was used resulting in an unnecessary shell invocation.

  • the xprop program was called for every window open on the system, although, often, none of that information is used.

  • to activate windows the package calls wmctrl with wmctrl -id -a <ID>, I was not sure what the d there is supposed to do, without it the command has the same effect/output.

After trying to patching some of these issues, and testing, exceptions would happen which forced me to abandon it, as it was less time consuming to start from scratch. With the knowledge gained writing emwh I found that the wmctrl package currently at least doesn’t handle window classes with spaces in them, nor does a program survive calling the library when there happens to be a window without a title somewhere on your desktop.

Most of the original tests included with the wmctrl library, work with only minor adjustments (which seem to have to do with my top-of-the-window menu) and a wrapper class in emwh. Moving from wmctrl to ewmh should therefore be easy.

Release files for ruamel.ewmh 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ruamel.ewmh 0.1.4
File Size Uploaded
ruamel.ewmh-0.1.4.tar.gz 10.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ruamel.ewmh 0.1.4
File Interpreter ABI Platform
ruamel.ewmh-0.1.4-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 20.1 kB

Release files / ruamel.ewmh-0.1.4.tar.gz

Download URL ruamel.ewmh-0.1.4.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e86882ea0e621ff1140a34924a0986c1031e6b5b87c2829fef3ba4af589d32c7
BLAKE2b-256 checksum
How to use checksums
f47a8d56ce29e9244590831398ba3bc773f57c7e268c53e44d5a47eeef8f4424
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / ruamel.ewmh-0.1.4-py2.py3-none-any.whl

Download URL ruamel.ewmh-0.1.4-py2.py3-none-any.whl
Size 9.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
960c0965e85352c63d653cdc6cd7f3a56836b608ba3275c8f102f9b4f676d091
BLAKE2b-256 checksum
How to use checksums
dcd3e1e0b66428e9331e9e38c14b50aecaa67e3a18771eb57634b9ca09976039
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page