def root(desktop=None): """ Return the root window for the current desktop. If the optional 'desktop' parameter is specified then attempt to use that particular desktop environment's mechanisms to look for windows. """ # NOTE: The desktop parameter is currently ignored and X11 is tested for # NOTE: directly. if _is_x11(): return Window(None) else: raise OSError, "Desktop '%s' not supported" % use_desktop(desktop)
def list(desktop=None): """ Return a list of windows for the current desktop. If the optional 'desktop' parameter is specified then attempt to use that particular desktop environment's mechanisms to look for windows. """ # NOTE: The desktop parameter is currently ignored and X11 is tested for # NOTE: directly. if _is_x11(): s = _readfrom(_get_x11_vars() + "xlsclients -a -l", shell=1) prefix = "Window " prefix_end = len(prefix) handles = [] for line in s.split("\n"): if line.startswith(prefix): handles.append(line[prefix_end:-1]) # NOTE: Assume ":" at end. else: raise OSError, "Desktop '%s' not supported" % use_desktop(desktop) return [Window(handle) for handle in handles]
def root(desktop=None): if _is_x11(): return Window(None) else: raise OSError("Desktop '%s' not supported" % use_desktop(desktop))