Exemplo n.º 1
0
def windows(result_fun, prefix_complete=False, homogenous=False, 
            current_desk=False):
    global currentPrompt

    desks = range(0, ewmh.get_number_of_desktops().reply())
    names = ewmh.get_desktop_names().reply()

    content = {}
    for d in desks:
        if current_desk and state.desktop != d:
            continue

        name = d
        if d < len(names):
            name = names[d]

        content[name] = []

    clients = ewmh.get_client_list_stacking().reply()
    for c in reversed(clients):
        nm = ewmh.get_wm_desktop(c).reply()
        if nm < len(names):
            nm = names[nm]
        if nm in content:
            wm_name = ewmh.get_wm_name(c).reply()
            if not wm_name:
                wm_name = icccm.get_wm_name(c).reply()
            if not wm_name or not isinstance(wm_name, basestring):
                wm_name = 'N/A'
            content[nm].append((wm_name, c))

    currentPrompt = Prompt(content, result_fun, prefix_complete, homogenous)
Exemplo n.º 2
0
    def wmname(self):
        if isinstance(self._wmname, util.PropertyCookie):
            self._wmname = self._wmname.reply()

            # If nothing, check WM_NAME...
            if self._wmname is None:
                self._wmname = icccm.get_wm_name(conn, self.id).reply()

            # Still nothing... empty string
            if self._wmname is None:
                self._wmname = ''

        return self._wmname
Exemplo n.º 3
0
def icon_for_window(window):
    """Try all window classes and use the first one we have an icon for."""
    name = get_wm_name(window.window).reply()
    classes = get_wm_class(window.window).reply()

    if name:
        name = name[0].split()[0]
        if name in WINDOW_ICONS:
            return WINDOW_ICONS[name]

    if classes:
        for cls in classes:
            cls = cls.lower()  # case-insensitive matching
            if cls in WINDOW_ICONS:
                return WINDOW_ICONS[cls]
    logging.info('No icon available for window with classes: %s' %
                 str(classes))
    return DEFAULT_ICON
Exemplo n.º 4
0
    def update_title(self, atom):
        """
        Updates the 'wmname' attribute of a window object. Prefers EWMH and
        falls back to ICCCM if necessary. If no name can be found, use an empty
        string.
        """
        assert atom in ('_NET_WM_NAME', 'WM_NAME')

        # If the window has a _NET_WM_NAME property, ignore WM_NAME
        if atom == 'WM_NAME' and aid('_NET_WM_NAME') in self.win.properties:
            return

        new_name = ''
        if atom == '_NET_WM_NAME':
            new_name = ewmh.get_wm_name(state.conn, self.win.id).reply()
        elif atom == 'WM_NAME':
            new_name = icccm.get_wm_name(state.conn, self.win.id).reply()

        # Don't update if it's the same...
        if new_name == self.win.wmname:
            return

        self.win.wmname = new_name
Exemplo n.º 5
0
 def get_wm_name(self):
     return icccm.get_wm_name(self.win).reply()
Exemplo n.º 6
0
 def get_wm_name(self):
     return icccm.get_wm_name(self.win).reply()