summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Frank Erikson <kristian@dingey.(none)>2008-12-24 14:17:38 +1300
committerKristian Frank Erikson <kristian@dingey.(none)>2008-12-24 14:17:38 +1300
commit62142fe9fe3bf0acf9fe6a401548e848e4fa4193 (patch)
tree1b9a2c2644e0509ebba683559714e4c1754468ea
parent4b5f8f567c5ae32255dac874faba05d9a5e20590 (diff)
downloadpython-compiz-manager-62142fe9fe3bf0acf9fe6a401548e848e4fa4193.tar.gz
python-compiz-manager-62142fe9fe3bf0acf9fe6a401548e848e4fa4193.tar.bz2
Started adding new WindowList class for storing information about all windows.
-rwxr-xr-xCompizManager.py54
1 files changed, 46 insertions, 8 deletions
diff --git a/CompizManager.py b/CompizManager.py
index 1905d72..0e504ee 100755
--- a/CompizManager.py
+++ b/CompizManager.py
@@ -19,6 +19,9 @@
# Author: Kristian F. Erikson <kristian@erikson.dk>
#
+# I am still new to using python. So you find any code that's not 'good' python
+# please flick me an email so I can correct it :)
+
import dbus
import xml.etree.ElementTree
import time
@@ -166,14 +169,33 @@ class CompizManager(object):
import string
""" Return a dictionary with attributes for each window, including info "xwininfo" returns as well as
Compiz Fusion specific details like which viewport or face of the cube, etc. -- Not implemented """
- # Go get the list of available
+ # Go get the list of windows
+
+ # Implementation using wmctrl for getting list of windows
+ """
+ wmctrl = os.popen("wmctrl -l")
+ wmctrl = wmctrl.read()
+ outputWindowList = string.splitfields(wmctrl, '\n')
+ print outputWindowList
+ for window in outputWindowList: # Parse each string's window info
+ windowinfo = string.splitfields(window, ' ')
+ print windowinfo[0]
+ print windowinfo[1]
+ print windowinfo[2]
+ print windowinfo[3]
+ """
+
+ # Implementation using xwininfo for getting list of windows
xwininfo = os.popen("xwininfo -root -children")
xwininfo = xwininfo.read()
childrenIndex = string.rindex(xwininfo, 'children') # Discard unnecessary output
windowsString = xwininfo[(childrenIndex+10):]
windowsString = windowsString.rstrip()
outputWindowList = string.splitfields(windowsString, '\n')
+ count = 0
+ windowList = WindowList()
for window in outputWindowList: # Parse each string's window info
+ count = count + 1
window = window.lstrip() # Strip left spaces
firstSpace = window.find(' ') # Find the first space
windowId = int(window[:firstSpace], 16) # Extract window id
@@ -188,10 +210,26 @@ class CompizManager(object):
if window[firstSpace+1] == '"':
secondQuote = window.find('"', firstSpace+3)
windowName = window[firstSpace+2:secondQuote] # Get the window name
- print windowName
- print windowId
+ windowList.addWindow(windowName, windowId)
+ print windowList.windowInfo(windowName)
return window
+class WindowList(object):
+ """ Attributes for each window, including info "xwininfo" returns as well as
+ Compiz Fusion specific details like which viewport or face of the cube, etc. """
+
+ # Next thing to do - start adding all the missing attributes
+
+ def __init__(self):
+ self.windows = {}
+
+ def addWindow(self, title, windowId): # add other attributes in a dict.. All keyed by the title
+ self.windows[title] = windowId
+
+ def windowInfo(self, title): # Temp func for printing windows - dev
+ self.windows[title]
+ return 'Window title: ' + title + ' id: ' + str(self.windows[title])
+
def AllToScreen():
""" Prints all Plugins with their actions and options to the screen """
@@ -218,14 +256,14 @@ if __name__ == '__main__':
# Set a global manager for the tests:
manager = CompizManager()
- from CompizTests import *
+ # from CompizTests import *
# Pre test setup
- preTestSetup()
+ # preTestSetup()
# Run the tests
- suite = unittest.TestLoader().loadTestsFromTestCase(TestCompizManagerClasses)
- unittest.TextTestRunner(verbosity=2).run(suite)
+ # suite = unittest.TestLoader().loadTestsFromTestCase(TestCompizManagerClasses)
+ # unittest.TextTestRunner(verbosity=2).run(suite)
# Run the test cleanup
- postTestCleanup()
+ # postTestCleanup()
# Print a file with actions and options listed in it
AllToFile('Plugins with options and actions.txt')