예제 #1
0
    def set_dimensions(self, dimensions):
        """Modify the width and heigth dimensions of a window.

        Args:
            dimensions (dict): {w}idth and {h}eigth.
        """

        Window.unmaximize(title=self.title)
        Shell.check_output('xdotool windowsize {} {w} {h}'.format(self.window_id, **
                                                                  dimensions))
예제 #2
0
    def set_position(self, position):
        """Modify the xy position of a window.

        Args:
            position (dict): {x}{y} coordinates.
        """

        Window.unmaximize(title=self.title)
        Shell.check_output('xdotool windowmove {} {x} {y}'.format(self.window_id, **
                                                                  position))
예제 #3
0
    def unmaximize(cls, title):
        """Removes all maximized window-decorators.

        Args:
            title (str): the search string to pass to wmctrl.
        """

        instruction = 'wmctrl -r "{}" -b remove,maximized_vert,maximized_horz' \
            .format(title)
        Shell.check_output(instruction)
예제 #4
0
    def title(self):
        """Call 'xdotool getwindowname {self.window_id}'.

        Returns:
            title (str)
        """

        return Shell.check_output('xdotool getwindowname %s' % self.window_id)
예제 #5
0
    def search(cls, title):
        """Search for a window-id by using the title."""

        id_results = Shell.check_output('xdotool search --name "%s"' % title)
        if isinstance(id_results, str):
            return id_results
        else:
            for id_result in id_results:
                try:
                    result_title = Shell.check_output('xdotool getwindowname {}'
                                                      .format(id_result))
                except:    # pylint: disable=bare-except
                    continue

                if result_title:
                    if title in result_title:
                        return id_result
예제 #6
0
    def geometry(self):
        """Call 'xdotool getwindowgeometry {self.window_id}'.

        Returns:
            geometry (list, len=3)
            False: if the self.window_id is not found.
        """

        return Shell.check_output('xdotool getwindowgeometry {}' \
                                                        .format(self.window_id))
예제 #7
0
    def desktop_number(self):
        """Call 'xdotool get_desktop_for_window {self.window_id}'.

        Returns:
            desktop (str, int-like): the Xorg virtual-desktop number the window
                has been assigned to. Compatible with `desktops_range`.
        """

        return Shell.check_output('xdotool get_desktop_for_window {}'.format(
            self.window_id))
예제 #8
0
    def virtual_desktops(cls):
        """Provides a count and range for the number of virtual-desktops in the
        current Xorg-environment.

        Additionally determines the lower/upper-bounds to return in the range.

        Returns:
            tuple:
                desktops (int): A natural-number representation of the number of
                    virtual desktops available.
                desktops_range (range): A determinable python-range which
                    represents the computer's counting of the desktops.
        """

        desktops = Shell.check_output('xdotool get_num_desktops')
        desktops = int(desktops)    # pylint: disable=redefined-variable-type

        desktop_zero_start = Shell.check_output('xdotool search --desktop 0 --name ".*"')
        if desktop_zero_start:
            desktops_range = range(desktops)
        else:
            desktops_range = range(1, desktops + 1)

        return (desktops, desktops_range)
예제 #9
0
    def window_ids(cls):
        """Returns a list of all windows available while also filtering empty
        desktops.

        Returns:
            list:
                window_ids
        """

        window_ids = []
        _, desktops_range = cls.virtual_desktops()
        for desktop_number in desktops_range:
            desktop_windows = Shell.check_output(
                'xdotool search --desktop {} --name ".*"'.format(desktop_number))
            if desktop_windows:    # Returns False if the desktop has no windows
                for window_id in desktop_windows:
                    window_ids.append(window_id)
        return window_ids