Hacking your window manager with Python

I was looking for a way to hack my window manager in Python. I want to use special piece of code to handle the window placement, or display stuffs in the background..

It looks like pyxfce meet my needs, so I decided to give it a try. The first thing to do is to build the latest svn of xfce. Next step play with the python wrapper.

Update: You don’t need the latest version (svn) of xfce. pyxfce works w/ xfce 4.2.1. The debian package is broken, as rely on a old libxfcegui (4.1)

Update 2: Debian package is fixed right now :)

Here is a little example of what you can do without too much pain. This script wait for every new window, and stack it on the same workspace as previous other windows of the same app. For example, the emacs windows is launched of the workspace ‘4′, all other emacs windows will be displayed on this workspace.

import sys
import xfce4
import gtk

black_list = ['xfrun4','Terminal']

def newWinHandler(screen,win):
name =  win.get_resource_name()

if name not in black_list:
for w in screen.get_windows():
if w != win and w.get_resource_name() == name:
dest = w.get_workspace()
win.move_to_workspace( dest )
break

screen = xfce4.netk.screen_get_default()
screen.connect("window-opened",newWinHandler)

gtk.main()

The major issue of pyxfce is the lack of documentation, you can do a lot of stuffs with it like creating custom xfce applications, but i didn’t find anything about this.

Related posts :

admin June 27th, 2005


3 Responses to “Hacking your window manager with Python”

  1. Anonymouson 06 Jul 2005 at 11:51 pm

    Why not just use kahakai or some such (something already implemented in python)? Then you can hack away to your heart’s content.

  2. Jkxon 09 Jul 2005 at 1:36 am

    Perhaps because, I already use xfce on all my computers because it’s small, efficient and now scriptable

  3. Adhikaon 06 Jul 2007 at 9:33 pm

    let me teach how to run this programm

Comments RSS

Leave a Reply