Пример #1
0
def get_window_class(window: Window) -> str:
    cls = None

    try:
        cls = window.get_wm_class()
    except Xlib.error.BadWindow:
        logger.warning("Unable to get window class, got a BadWindow exception.")

    # TODO: Is this needed?
    # nikanar: Indeed, it seems that it is. But it would be interesting to see how often this succeeds, and if it is low, maybe fail earlier.
    if not cls:
        print("")
        logger.warning("Code made an unclear branch")
        try:
            window = window.query_tree().parent
        except Xlib.error.XError as e:
            logger.warning("Unable to get window query_tree().parent, got a {} exception from Xlib".format(type(e).__name__))
            return "unknown"
        if window:
            return get_window_class(window)
        else:
            return "unknown"

    cls = cls[1]
    return cls
Пример #2
0
def get_window_class(window: Window) -> str:
    cls = None

    try:
        cls = window.get_wm_class()
    except Xlib.error.BadWindow:
        logger.warning(
            "Unable to get window class, got a BadWindow exception.")

    # TODO: Is this needed?
    if not cls:
        print("")
        logger.warning("Code made an unclear branch")
        window = window.query_tree().parent
        if window:
            return get_window_class(window)
        else:
            return "unknown"

    cls = cls[1]
    return cls