def windows_in_workspace(workspace): """ Generator to iterate over windows in a workspace. Args: workspace: The name of the workspace whose windows to iterate over. """ ws = get_workspace_tree(workspace) for con in windows_in_container(ws): # Get information on the window. try: window = Window.by_id(con['window'])[0] except ValueError as e: eprint(str(e)) continue # Pre-emptively attempt to catch error try: window except NameError as e: eprint(str(e)) continue if not window: continue yield (con, window)
def recalled(self): if not os.path.isfile(self.rrun_file): return try: window_id_hex = readfile(self.rrun_file) if window_id_hex.startswith('run'): return True # but we can't switch to the running window im_running = Window.by_id(int(window_id_hex, 16)) except Exception as e: print e ### return if im_running: writefile(self.rrun_file, 'run baby') im_running[0].activate() return True
def test_properties(): def get_geometry(w): return (w.x, w.y, w.w, w.h) # w1, xclock = get_win('xclock') assert 'maximized_vert' not in w1.wm_state assert 'maximized_horz' not in w1.wm_state w1.set_properties(("toggle", "maximized_vert", "maximized_horz")) # # get a new instance of w1, to re-read the wm_state w2 = Window.by_id(int(w1.id, 16))[0] assert not (get_geometry(w1) == get_geometry(w2)) assert 'maximized_vert' in w2.wm_state assert 'maximized_horz' in w2.wm_state