def toemptygroup(): QTILE_CLIENT = Client() empty_groups = [grp for grp in QTILE_CLIENT.groups().keys() if len(QTILE_CLIENT.groups()[grp]['windows']) == 0] if len(empty_groups) == 0: return QTILE_CLIENT.screen.toggle_group(empty_groups[0])
def ontop(title): c = Client() if title is None: title = c.group.window.info()['name'] print(title) with open(PATH, 'w+') as f_obj: f_obj.write(title) wid = [(w['id'], w['group']) for w in c.windows() if title == w['name']] if len(wid) == 0: os.remove(PATH) return c.window[wid[0][0]].bring_to_front() c.window[wid[0][0]].togroup() # This code runs only when the current group is changed, so that # correct window is focused instead of mpv window prv_grp = wid[0][1] cur_grp = c.group.info()['name'] focusHistory = c.groups()[c.group.info()['name']]['focusHistory'] if focusHistory[-1] == title and cur_grp != prv_grp: last_wid = [ w['id'] for w in c.windows() if w['name'] == focusHistory[-2] and w['group'] == cur_grp ][0] c.window[last_wid].focus()