def get_wmctrl_output(): """ Parses the output of wmctrl and returns a list of ordered dicts. """ assert fs.which("wmctrl"), "the program wmctrl was not found." # cmd = "wmctrl -lGpx" lines = [line for line in process.get_simple_cmd_output(cmd).split("\n") if line] res = [] for line in lines: # 0x05e000c7 0 4402 2562 298 638 540 truecrypt.Truecrypt jabba-uplink TrueCrypt pieces = line.split() d = OrderedDict() #d['wid'] = int(pieces[0], 16) # converted to decimal d['wid'] = pieces[0] d['desktop'] = int(pieces[1]) d['pid'] = int(pieces[2]) d['geometry'] = [int(x) for x in pieces[3:7]] d['window_class'] = pieces[7] d['client_machine_name'] = pieces[8] d['window_title'] = ' '.join(pieces[9:]) res.append(d) # return res
def get_wmctrl_output(): """ Parses the output of wmctrl and returns a list of ordered dicts. """ assert fs.which("wmctrl"), "the program wmctrl was not found." # cmd = "wmctrl -lGpx" lines = [ line for line in process.get_simple_cmd_output(cmd).split("\n") if line ] res = [] for line in lines: # 0x05e000c7 0 4402 2562 298 638 540 truecrypt.Truecrypt jabba-uplink TrueCrypt pieces = line.split() d = OrderedDict() #d['wid'] = int(pieces[0], 16) # converted to decimal d['wid'] = pieces[0] d['desktop'] = int(pieces[1]) d['pid'] = int(pieces[2]) d['geometry'] = [int(x) for x in pieces[3:7]] d['window_class'] = pieces[7] d['client_machine_name'] = pieces[8] d['window_title'] = ' '.join(pieces[9:]) res.append(d) # return res
def activate_window_by_id(wid): """ Put the focus on and activate the the window with the given ID. """ assert fs.which("xdotool"), "the program xdotool was not found." # os.system('xdotool windowactivate {wid}'.format(wid=wid))
def _decorator(fn): if not fs.which(fpath): print "Error: {f} doesn't exist".format(f=fpath) print "Traceback: {func}() in {src}".format(func=fn.__name__, src=__file__) sys.exit(1) # def step_func(*args, **kwargs): return fn(*args, **kwargs) return step_func
def toggle_fullscreen(wid_hexa): """ Toggle the given window to fullscreen. The window id is a hexa string. """ assert fs.which("wmctrl"), "the program wmctrl was not found." # cmd = "wmctrl -i -r {wid} -b toggle,maximized_vert,maximized_horz".format(wid=wid_hexa) os.system(cmd)
def toggle_fullscreen(wid_hexa): """ Toggle the given window to fullscreen. The window id is a hexa string. """ assert fs.which("wmctrl"), "the program wmctrl was not found." # cmd = "wmctrl -i -r {wid} -b toggle,maximized_vert,maximized_horz".format( wid=wid_hexa) os.system(cmd)
def get_window_title_by_id(wid): assert fs.which("xwininfo"), "the program xwininfo was not found." # result = get_simple_cmd_output('xwininfo -id {id}'.format(id=wid)) for line in StringIO(result): line = line.rstrip("\n") match = re.search(r'^xwininfo: Window id:.*"(.*)"$', line) if match: return match.group(1) # return None
def get_active_window_id(hexa=False): """ Window ID of the active window. The return value is a string. By default, the ID is in decimal format. If hexa is True, the return value is hexadecimal. In both cases, the return value is a string. """ assert fs.which("xdotool"), "the program xdotool was not found." # wid = get_simple_cmd_output('xdotool getactivewindow').strip() if not hexa: return wid else: return hex(int(wid))
def test_get_window_title_by_id(): # TODO assert fs.which('xwininfo') is not None
def test_lock_screen(): # TODO assert fs.which('gnome-screensaver-command') is not None
def test_get_active_window_id(): # TODO assert fs.which('xdotool') is not None
def toggle_fullscreen(): assert fs.which("wmctrl"), "the program wmctrl was not found." # wid = window.get_active_window_id(hexa=True) cmd = "wmctrl -i -r {wid} -b toggle,maximized_vert,maximized_horz".format(wid=wid) os.system(cmd)
def test_which(self): if sys.platform.startswith('linux'): cmd = 'bash' assert '/bin/bash' in fs.which(cmd) # can be /usr/bin/bash too else: print "# test_which is passed on this podium (TODO)"
def test_is_linux(): if fs.which('bash') == '/bin/bash': assert platform.is_linux()
def test_toggle_fullscreen(): # TODO assert fs.which('wmctrl') is not None
def test_lock_screen(): # TODO assert fs.which("gnome-screensaver-command") is not None
def test_is_linux(): if fs.which('bash') == '/bin/bash': assert podium.is_linux()