From 26570a759b1bab88b2706aaef4f5ca138adea606 Mon Sep 17 00:00:00 2001 From: Ben Burrill Date: Mon, 8 Jan 2018 13:19:56 -0800 Subject: [PATCH] Only fallback to cmd identifier when needed Using the cmd identifier is quite problematic. If it contains null bytes, it will result in an error farther down the line, causing the group not to be shown! This change makes cmd act in the same way as the window title, in that res_class and res_name are preferred. It is probably wise to split cmd by null bytes and choose only the first one, but since I am unsure of all the potential ramifications of such a change (would it be better to replace null bytes with spaces?) and because this change fixes the problem for me, I will not include that in this commit. --- dockbarx/dockbar.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dockbarx/dockbar.py b/dockbarx/dockbar.py index 0a79434..b707a03 100644 --- a/dockbarx/dockbar.py +++ b/dockbarx/dockbar.py @@ -907,7 +907,7 @@ def __add_window(self, window): res_class = window.get_class_group().get_res_class().lower() res_name = window.get_class_group().get_name().lower() if window.has_name(): - identifier = res_class or res_name or window.get_name().lower() + fallback = window.get_name().lower() else: #in case window has no name - issue with Spotify pid = window.get_pid() @@ -917,9 +917,10 @@ def __add_window(self, window): raise cmd = f.readline() if "/" in cmd: - identifier = cmd.split("/")[-1] + fallback = cmd.split("/")[-1] else: - identifier = cmd + fallback = cmd + identifier = res_class or res_name or fallback # Special cases if identifier in SPECIAL_RES_CLASSES: identifier = SPECIAL_RES_CLASSES[identifier]