Ported back to Qt3/KDE3
[switcha.git] / wmctrl.py
blobc1f07d33d0793d8849f5300bff4600b8230fb281
1 import os
2 import re
4 BLACKLIST=[
5 "KDE Desktop",
6 "kicker"
9 reSimplify = re.compile(" +")
10 def simplifySpaces(txt):
11 return reSimplify.sub(" ", txt)
14 def runWmCtrl(*args):
15 cmd = ["wmctrl"]
16 cmd.extend(args)
17 sin, sout = os.popen2(cmd)
18 sin.close()
19 lines = [simplifySpaces(x.strip()) for x in sout.readlines()]
20 return lines
23 def getWindowList():
24 """0x032000e1 0 cpc6128 Qt Designer"""
25 lines = runWmCtrl("-l")
26 lst = []
27 for line in lines:
28 tokens = line.split(" ")
29 wid = tokens[0]
30 text = " ".join(tokens[3:])
31 if text not in BLACKLIST:
32 lst.append( (text, wid) )
33 return lst
36 def switchToWindow(wid):
37 runWmCtrl("-ia", wid)