Python Window Manager
PYWM is a small, simple python-programmable X window manager that's
packed with features yet very easy to learn and use.
Some window managers are mouse heaven and keyboard hell. Other window
managers are the other way around.
But PYWM aims to be very comfortable to use from either.
PYWM is a "pythonised" version of the fast light FLWM window
manager, and gives you easy-to-use tools to create your own personal
dream desktop. Control Freak Heaven.
So What Can I Do With It?
All sorts of stuff, limited only by your imagination. Here's a short
(and very incomplete) list:
- Infinite-sized desktop with keyboard panning (and zooming!!)
- Ability to create new desktops on the fly
- 'Lock' certain windows, so they won't be moved or resized during
zooming or panning.
- Move/resize/close individual windows with key bindings
- Detect when windows are created/destroyed/moved/resized, and take
- For instance, detect certain applications, and move/resize them
- Set timers, to take actions once or repeatedly (one of the examples has a function called
'hallucinate' which randomly moves/resizes all the windows on the
- Turn window borders and
titlebars on and off
- Dock unrelated application windows together. Or, if one
application is started, launch another one automatically
- Diaplay a different wallpaper when each given window is activated
(would you really want this???)
- Have a different set of key bindings for each active window
- In addition to this, I'm currently working on an (FLTK-based) API
to allow you to create 'in-window-manager' windows, so you can very
easily build your own applets.
(Also, I'm hoping at some time to incorporate joystick-driven zoom/pan
(anyone wanna volunteer?)
I've seen dozens of window managers in my time.
At one extreme are the morbidly obese KDE and Gnome desktops, which can
take longer to fire up than Linux itself! One wonders if development of
these two projects is funded by manufacturers of memory and hard disks
At the other extreme are hard-core 'minimalist' window managers like
'LWM' and 'TWM', which can be very functionality-challenged, or have
some annoying quirks. For example, one WM I tried requires you to hold
down the ALT key while using the mouse within a window!
On the fringes are 'rodentophobic' window managers like Matchbox,
RatPoison, Ion etc. One thinks of certain people (who will go nameless)
who take pride in still using ASCII dumb terminals.
On the advanced end of the spectrum is the wonderful LISP-driven
'Sawfish' window manager.
But PyWM is aimed at the middle ground. On one hand, it's easy to set
up magickal key bindings to do pretty much what you want. But on the
other hand, it's also comfortable and courteous for mouse users. I find
myself often switching from mouse/keyboard to straight keyboard, so
PyWM is there for me all the way.
And, above all, it's built to support easy
customisation in Python,
the world's coolest
What's the Python Scenario?
I've taken the FLWM
window manager and wrapped it into a Python module as a 'window manager
You drive PYWM by creating a subclass of the basic pywm.WM window manager class. If
you want even more per-window control, you can subclass the pywm.window class as well. Plenty of
examples in the PYWM distribution you can use as a starting point.
If you like, why not browse the documentation
Within your derived classes, you write event handlers, which receive
all kinds of window manager related events, and within the event handler
methods, can pick from a large range of actions.
The PyWM API is kept clean, simple and intuitive. So you won't be
dragging your ass through unreadable source code and
incomplete/inaccurate documentation for hours just to figure out how to
do basic stuff. There are some
programmers who get a perverse rush from making their APIs as
complicated and obscure as possible. For example, in raw X, it takes 12
args to a function to get just the title of a window! But that's not
how I work...
Within your handlers, you can:
Your handlers can receive events, such as:
- Move/resize windows
- Hide/Show/Close windows
- Launch other apps
- Switch between desktops
- Dynamically bind, rebind and unbind keystrokes
- Create screen 'hotspots' and 'hot-edges' - which are activated
when the mouse goes to an area on the screen (or clicks there).
- Set timers to fire your own callbacks - once or repeatedly
In contrast to other Python-driven window managers, this one is so easy
and intuitive that you'll be hacking your own window manager script in a
couple of minutes. A set of easily-undersood example scripts is included
with the distribution.
- Window manager startup
- Window gets created
- Window gets destroyed
- Mouse enters a window
- Window gets moved or resized
- Custom key sequence is received
- Mouse click is received
- Timers (set by yourself)
Caveat - due to some quirks in Pyrex, some exceptions may not appear on
stdout - if things ever look weird, just sprinkle in a few print
statements while debugging, until you figure out what's happening.
Also, while you're testing/debugging your Python script, you're best
advised to put 'xterm' in your .xinitrc, and launch your script
manually within the xterm window.
What Do I Need?
- Python 2.2
- Pyrex - the Python<->C wrapper generator: http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/
(only if building from source)
- FLTK version 1.0 - available from here
on the FLTK
homepage (only if building from source)
- The Leo
metastructural code editor (optional) - makes the source much more
- if your system has glibc 2.2 or later, and Python 2.2.1 or later,
you can save yourself the need to download/install/compile FLTK 1.0 and
and use the precompiled binary flwm_.so module in the tarball.
Where's It At?
PyWM is in a prototype state, but it's
working well enough to offer for download and review.
Be warned that if your scripting has errors, it can take the X server
down with it, killing off your apps and causing possible loss of data.
There may also be bugs in the FLWM core, or in the PyWM code, which
cause stability problems as well.
So if you want to play around with PyWM, please observe the following:
- While working on your scripts, write your ~/.xinitrc file to
launch xterm (or your favourite console window). Launch your PyWM
script from within this console. That way, if your script crashes (and
doesn't take down X), you can fix it and re-launch it
- Never, NEVER have any applications open with important data while
you're working on your PyWM scripts. Don't trust your script until
you've tested it thoroughly.
- When running other applications within your PyWM environment, be
sure to save your data often.
- If you see any really weird and unexplainable things happening on
your desktop, or apps refusing to run, try restarting the X server. If
this doesn't work, try rebooting.
I'm Curious - Gimme a Copy!
Download PYWM here
Page updated June 2,
2003 by David McNab