From 7f17d6f3971e8d621a5444e70e33645c249d4049 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Thu, 8 Jul 2021 14:25:14 +0200 Subject: [PATCH] i3-companion: only consider instance/class for icon Name may be too random. Straighten a bit the regex too to avoid matching on prefixes. --- bin/i3-companion | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/bin/i3-companion b/bin/i3-companion index 74ea201..667d5f2 100755 --- a/bin/i3-companion +++ b/bin/i3-companion @@ -50,9 +50,9 @@ application_icons = { "steam": "", "vbeterm": "", "zathura": "", - "zoom": "", - "NOMATCH": "" + "zoom": "" } +application_icons_nomatch = "" application_icons_alone = { application_icons[k] for k in { "vbeterm" @@ -69,17 +69,16 @@ async def workspace_rename(i3, event): def application_icon(window): """Get application icon for a window.""" - for attr in ('name', - 'window_instance', + for attr in ('window_instance', 'window_class'): name = getattr(window, attr, None) if name is None: continue for k, v in application_icons.items(): - if re.match(k, name, re.IGNORECASE): + if re.match(rf"^{k}\b", name, re.IGNORECASE): logger.debug(f"in {attr}, found '{name}', matching {k}") return v - return application_icons["NOMATCH"] + return application_icons_nomatch for workspace in workspaces: icons = set()