Skip to content

Fedora 43 KDE Plasma: Exception thrown while trying to get active window #114

@merken

Description

@merken
Exception thrown while trying to get active window  (aw_watcher_window.main:140)
Traceback (most recent call last):
  File "aw_watcher_window/main.py", line 122, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 64, in get_current_window
  File "aw_watcher_window/lib.py", line 17, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 85, in get_window_name
AttributeError: 'NoneType' object has no attribute 'decode'

The error above happens in the current release 0.13.2 as well as building and running from source.

Making the following changes to aw-watcher-window/aw-watcher-window/xlib.py on line 75 fixes the problem, since the variable r is a NoneType:

 if d is None or d.format != 8:
        try:
            # Fallback.
            r = window.get_wm_name()
            if isinstance(r, str):
                return r
            else:
                # r is None, this causes a crash, so returning unkown until a fix is found
                if r is None:
                    return "unknown"
                logger.warning(
                    "I don't think this case will ever happen, but not sure so leaving this message here just in case."
                )
                return r.decode("latin1")  # WM_NAME with type=STRING.
        except Xlib.error.BadWindow as e:
            # I comment on the log, the number of messages that pop up is very annoying
            # Also, it does not give much information about the error
            # But I leave it in case someone sees it useful
            # logger.warning(
            #     f"Unable to get window property WM_NAME, got a {type(e).__name__} exception from Xlib"
            # )
            return "unknown"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions