Python Xlib.X.AnyPropertyType() Examples

The following are 8 code examples of Xlib.X.AnyPropertyType(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module Xlib.X , or try the search function .
Example #1
Source File: x11.py    From darkc0de-old-stuff with GNU General Public License v3.0 6 votes vote down vote up
def formatWindow(window):
    name = window.get_wm_name()
    info = []
    if name:
        info.append(name)

    geometry = window.get_geometry()
    info.append('%sx%sx%s at (%s,%s)' % (
        geometry.width, geometry.height, geometry.depth,
        geometry.x, geometry.y))

    atom = InternAtom(display=window.display, name="_NET_WM_PID", only_if_exists=1)
    pid = window.get_property(atom.atom, AnyPropertyType, 0, 10)
    if pid:
        pid = int(pid.value.tolist()[0])
        info.append('PID=%r' % pid)

    info.append("ID=0x%08x" % window.id)
    return '; '.join(info) 
Example #2
Source File: ewmh.py    From pyewmh with GNU Lesser General Public License v3.0 5 votes vote down vote up
def _getProperty(self, _type, win=None):
        if not win:
            win = self.root
        atom = win.get_full_property(self.display.get_atom(_type),
                                     X.AnyPropertyType)
        if atom:
            return atom.value 
Example #3
Source File: xlib.py    From aw-watcher-window with Mozilla Public License 2.0 5 votes vote down vote up
def _get_current_window_id() -> Optional[int]:
    atom = display.get_atom("_NET_ACTIVE_WINDOW")
    window_prop = screen.root.get_full_property(atom, X.AnyPropertyType)

    if window_prop is None:
        logger.warning("window_prop was None")
        return None

    # window_prop may contain more than one value, but it seems that it's always the first we want.
    # The second has in my attempts always been 0 or rubbish.
    window_id = window_prop.value[0]
    return window_id if window_id != 0 else None 
Example #4
Source File: xlib.py    From aw-watcher-window with Mozilla Public License 2.0 5 votes vote down vote up
def get_window_pid(window: Window) -> str:
    atom = display.get_atom("_NET_WM_PID")
    pid_property = window.get_full_property(atom, X.AnyPropertyType)
    if pid_property:
        pid = pid_property.value[-1]
        return pid
    else:
        # TODO: Needed?
        raise Exception("pid_property was None") 
Example #5
Source File: get_selection.py    From python-xlib with GNU Lesser General Public License v2.1 5 votes vote down vote up
def handle_incr(d, w, data_atom, target_name):
    # This works by us removing the data property, the selection owner
    # getting a notification of that, and then setting the property
    # again with more data.  To notice that, we must listen for
    # PropertyNotify events.
    w.change_attributes(event_mask = X.PropertyChangeMask)

    while True:
        # Delete data property to tell owner to give us more data
        w.delete_property(data_atom)

        # Wait for notification that we got data
        while True:
            e = d.next_event()
            if (e.type == X.PropertyNotify
                and e.state == X.PropertyNewValue
                and e.window == w
                and e.atom == data_atom):
                break

        r = w.get_full_property(data_atom, X.AnyPropertyType,
                                sizehint = 10000)

        # End of data
        if len(r.value) == 0:
            return

        output_data(d, r, target_name)
        # loop around 
Example #6
Source File: drawable.py    From python-xlib with GNU Lesser General Public License v2.1 5 votes vote down vote up
def get_full_text_property(self, property, property_type=X.AnyPropertyType, sizehint = 10):
        prop = self.get_full_property(property, property_type,
                                      sizehint=sizehint)
        if prop is None or prop.format != 8:
            return None
        if prop.property_type == Xatom.STRING:
            prop.value = prop.value.decode(self._STRING_ENCODING)
        elif prop.property_type == self.display.get_atom('UTF8_STRING'):
            prop.value = prop.value.decode(self._UTF8_STRING_ENCODING)
        # FIXME: at least basic support for compound text would be nice.
        # elif prop.property_type == self.display.get_atom('COMPOUND_TEXT'):
        return prop.value 
Example #7
Source File: drawable.py    From MIA-Dictionary-Addon with GNU General Public License v3.0 5 votes vote down vote up
def get_full_text_property(self, property, property_type=X.AnyPropertyType, sizehint = 10):
        prop = self.get_full_property(property, property_type,
                                      sizehint=sizehint)
        if prop is None or prop.format != 8:
            return None
        if prop.property_type == Xatom.STRING:
            prop.value = prop.value.decode(self._STRING_ENCODING)
        elif prop.property_type == self.display.get_atom('UTF8_STRING'):
            prop.value = prop.value.decode(self._UTF8_STRING_ENCODING)
        # FIXME: at least basic support for compound text would be nice.
        # elif prop.property_type == self.display.get_atom('COMPOUND_TEXT'):
        return prop.value 
Example #8
Source File: ewmh.py    From deepin-remote-assistance with GNU General Public License v3.0 5 votes vote down vote up
def _getProperty(self, _type, win=None):
		if not win: win = self.root
		atom = win.get_full_property(self.display.get_atom(_type), X.AnyPropertyType)
		if atom: return atom.value