def select_only(self, apps): if isinstance(apps, list): for app in apps: if self.select(app): break success = True try: sh.wmctrl("-x", "-a", apps) except sh.ErrorReturnCode: success = False return success
def select(self, apps): if isinstance(apps, list): for app in apps: if self.select(app): break success = True try: sh.wmctrl("-x", "-a", apps) except sh.ErrorReturnCode: success = False sh.xdotool("key", "Escape") return success
def goto_desktop(cls, desktop=None): if desktop is None: desktop = cls.desktop x = desktop.x * cls.work_area.width y = desktop.y * cls.work_area.height wmctrl('-o', '%s,%s' % (x, y))
def load(cls): line = wmctrl(d=True).strip().split() cls.full_area = cls.calculate_fa(*line[3].split('x')) cls.work_area = cls.calculate_wa(*(line[7].split(',') + line[8].split('x'))) cls.desktop = cls.calculate_desktop(cls.work_area, *line[5].split(','))
def load(self, filename=None): if filename is None: self.windows = [Window(x) for x in wmctrl(p=True, G=True, l=True)] else: with open(filename, 'rb') as f: self.windows = pickle.load(f)
def wmctrl(self, option, args): # print('-i', '-r', self.id, option, ','.join(args)) wmctrl('-i', '-r', self.id, option, ','.join(args))
def get_window_ids(): """ Return a list of x11 window IDs managed by the window manager. """ return [i.split(" ")[0] for i in wmctrl("-l").split("\n") if i.strip()]