summaryrefslogtreecommitdiff
path: root/CompizManager.py
diff options
context:
space:
mode:
Diffstat (limited to 'CompizManager.py')
-rwxr-xr-xCompizManager.py38
1 files changed, 31 insertions, 7 deletions
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()