python icon indicating copy to clipboard operation
python copied to clipboard

[window_switcher] Fix WM_CLASS with an unexpected number of parts

Open saierd opened this issue 4 years ago • 0 comments

Closes albertlauncher/albert#967.

Usually the WM_CLASS printed by wmctrl has two parts (instance and class name), separated by a dot. There are cases where this is not true:

  • Chrome's picture-in-picture window shows a WM_CLASS of N/A (see albertlauncher/albert#967).
  • Nautilus / Gnome Files on Ubuntu 20.04 shows a WM_CLASS value of 'org.gnome.Nautilus.Org.gnome.Nautilus', indicating the instance name 'org.gnome.Nautilus' with the class 'Org.gnome.Nautilus'.

Both cases previously lead to a ValueError due to the unexpected number of parts after the split.

We now handle the second case by splitting the list of dot-separated parts in the middle, assuming both pieces have the same number of parts. As a fallback, we use the whole WM_CLASS as the instance name, which should also cover the case of the Chrome window.

saierd avatar Apr 05 '21 09:04 saierd