summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Frank Erikson <kristian@kristian-desktop.(none)>2008-12-18 22:27:41 +1300
committerKristian Frank Erikson <kristian@kristian-desktop.(none)>2008-12-18 22:27:41 +1300
commit4b5f8f567c5ae32255dac874faba05d9a5e20590 (patch)
tree2aeb4f551613e63d8eae83171fe5e49d055f9c33
parentbe046ce32cef98d22c58cf729b0cebb0632f6208 (diff)
downloadpython-compiz-manager-4b5f8f567c5ae32255dac874faba05d9a5e20590.tar.gz
python-compiz-manager-4b5f8f567c5ae32255dac874faba05d9a5e20590.tar.bz2
Finally managed to get the massive amount of output from xwininfo down to the actual viable active windows :D
-rw-r--r--CompizError.py2
-rwxr-xr-xCompizManager.py38
-rwxr-xr-xCompizPlugin.py6
3 files changed, 35 insertions, 11 deletions
diff --git a/CompizError.py b/CompizError.py
index 28f5db8..c48b261 100644
--- a/CompizError.py
+++ b/CompizError.py
@@ -26,7 +26,7 @@ class CompizNotActiveError(CompizError):
return 'The library failed to connect to Compiz. Please ensure compiz is running and the dbus plugin is activated.'
class CompizPluginNameError(CompizError):
def __str__(self):
- return 'Plugin name not found in list of availiable plugins.'
+ return 'Plugin name not found in list of available plugins.'
class CompizPluginOptionError(CompizError):
def __str__(self):
return 'Plugin option not found.'
diff --git a/CompizManager.py b/CompizManager.py
index d537ec0..1905d72 100755
--- a/CompizManager.py
+++ b/CompizManager.py
@@ -78,7 +78,7 @@ class CompizManager(object):
else: raise CompizNotActiveError
def listAllPlugins(self): # List all avaible plugins
- """ Returns a list of all availiable Compiz plugins (active and inactive) """
+ """ Returns a list of all available Compiz plugins (active and inactive) """
if self.active: return self.pluginNameList
else: raise CompizNotActiveError
@@ -161,14 +161,37 @@ class CompizManager(object):
plugin.doAction(action, parameters)
else: raise CompizNotActiveError
- def listAllWindows():
+ def listAllWindows(self):
+ import os
+ 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 """
- # TODO: Implement
- pass
+ Compiz Fusion specific details like which viewport or face of the cube, etc. -- Not implemented """
+ # Go get the list of available
+ 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')
+ for window in outputWindowList: # Parse each string's window info
+ window = window.lstrip() # Strip left spaces
+ firstSpace = window.find(' ') # Find the first space
+ windowId = int(window[:firstSpace], 16) # Extract window id
+ # Go find out if mapped from xwininfo
+ xwininfo = os.popen("xwininfo -id " + str(windowId) + " -stats")
+ xwininfo = xwininfo.read()
+ viewableCheck = xwininfo.find('IsViewable') # Check if we can see it.. Not not point otherwise
+ colormapCheck = xwininfo.find('Colormap: 0x0 (not installed)')
+ stateCheck = xwininfo.find('State: yes')
+ if viewableCheck != (-1) and colormapCheck == (-1) and stateCheck == (-1):
+ secondSpace = window.find(' ', firstSpace+1) # Find the next space
+ if window[firstSpace+1] == '"':
+ secondQuote = window.find('"', firstSpace+3)
+ windowName = window[firstSpace+2:secondQuote] # Get the window name
+ print windowName
+ print windowId
+ return window
-
-
def AllToScreen():
""" Prints all Plugins with their actions and options to the screen """
@@ -206,4 +229,5 @@ if __name__ == '__main__':
# Print a file with actions and options listed in it
AllToFile('Plugins with options and actions.txt')
+ manager.listAllWindows()
diff --git a/CompizPlugin.py b/CompizPlugin.py
index 1ca6e65..ca36d14 100755
--- a/CompizPlugin.py
+++ b/CompizPlugin.py
@@ -34,11 +34,11 @@ class CompizPlugin(object):
Instances of the CompizPlugin are intended to represent an active or inactive Compiz plugin.
Each instance of a plugin loads it's options (variables we can change) from accessing what is
- availiable over the Dbus for the particular plugin.
+ available over the Dbus for the particular plugin.
Actions (or methods) are mainly the visual effects we can call (they're normally associated
- with a button or keypress, but not limited to these). The dict of availiable actions
- is built by accessing what is availiable over the Dbus. However as actions often require
+ with a button or keypress, but not limited to these). The dict of available actions
+ is built by accessing what is available over the Dbus. However as actions often require
additional arguments these are spefified in "plugins.xml". This is because the arguments are
not exposed over the Dbus. If an action does not work, determining if arguments are missing
is a goodplace to start.