aboutsummaryrefslogtreecommitdiff
path: root/contrib/autoname-workspaces.py
diff options
context:
space:
mode:
authorAljaz Gantar <gantar.aljaz94@gmail.com>2021-03-31 13:47:36 +0200
committerKenny Levinsen <kl@kl.wtf>2021-04-09 22:08:53 +0200
commit1a0f86be4eb23b76ab8384db0b61879ab51d5096 (patch)
treefb96150a2d78310f21a30333acc418d382142044 /contrib/autoname-workspaces.py
parent61df9eb62a6610361d42a7d5552cdddb3063db8a (diff)
refactor icon_for_window function
Diffstat (limited to 'contrib/autoname-workspaces.py')
-rwxr-xr-xcontrib/autoname-workspaces.py28
1 files changed, 11 insertions, 17 deletions
diff --git a/contrib/autoname-workspaces.py b/contrib/autoname-workspaces.py
index 2b634eee..3ec39928 100755
--- a/contrib/autoname-workspaces.py
+++ b/contrib/autoname-workspaces.py
@@ -22,24 +22,17 @@ DEFAULT_ICON = "󰀏"
def icon_for_window(window):
- app_id = window.app_id
- if app_id is not None and len(app_id) > 0:
- app_id = app_id.lower()
- if app_id in WINDOW_ICONS:
- return WINDOW_ICONS[app_id]
- logging.info("No icon available for window with app_id: %s" % str(app_id))
- else:
- # xwayland support
- class_name = window.window_class
- if class_name is not None and len(class_name) > 0:
- class_name = class_name.lower()
- if class_name in WINDOW_ICONS:
- return WINDOW_ICONS[class_name]
- logging.info(
- "No icon available for window with class_name: %s" % str(class_name)
- )
- return DEFAULT_ICON
+ name = None
+ if window.app_id is not None and len(window.app_id) > 0:
+ name = window.app_id.lower()
+ elif window.window_class is not None and len(window.window_class) > 0:
+ name = window.window_class.lower()
+
+ if name in WINDOW_ICONS:
+ return WINDOW_ICONS[name]
+ logging.info("No icon available for window with name: %s" % str(name))
+ return DEFAULT_ICON
def rename_workspaces(ipc):
for workspace in ipc.get_tree().workspaces():
@@ -128,3 +121,4 @@ if __name__ == "__main__":
rename_workspaces(ipc)
ipc.main()
+