aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorLibravatar Aljaz Gantar <gantar.aljaz94@gmail.com>2021-03-31 13:47:36 +0200
committerLibravatar Kenny Levinsen <kl@kl.wtf>2021-04-09 22:08:53 +0200
commit1a0f86be4eb23b76ab8384db0b61879ab51d5096 (patch)
treefb96150a2d78310f21a30333acc418d382142044 /contrib
parentfix type error when class_name none (diff)
downloadsway-1a0f86be4eb23b76ab8384db0b61879ab51d5096.tar.gz
sway-1a0f86be4eb23b76ab8384db0b61879ab51d5096.tar.zst
sway-1a0f86be4eb23b76ab8384db0b61879ab51d5096.zip
refactor icon_for_window function
Diffstat (limited to 'contrib')
-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 = "󰀏"
22 22
23 23
24def icon_for_window(window): 24def icon_for_window(window):
25 app_id = window.app_id 25 name = None
26 if app_id is not None and len(app_id) > 0: 26 if window.app_id is not None and len(window.app_id) > 0:
27 app_id = app_id.lower() 27 name = window.app_id.lower()
28 if app_id in WINDOW_ICONS: 28 elif window.window_class is not None and len(window.window_class) > 0:
29 return WINDOW_ICONS[app_id] 29 name = window.window_class.lower()
30 logging.info("No icon available for window with app_id: %s" % str(app_id)) 30
31 else: 31 if name in WINDOW_ICONS:
32 # xwayland support 32 return WINDOW_ICONS[name]
33 class_name = window.window_class
34 if class_name is not None and len(class_name) > 0:
35 class_name = class_name.lower()
36 if class_name in WINDOW_ICONS:
37 return WINDOW_ICONS[class_name]
38 logging.info(
39 "No icon available for window with class_name: %s" % str(class_name)
40 )
41 return DEFAULT_ICON
42 33
34 logging.info("No icon available for window with name: %s" % str(name))
35 return DEFAULT_ICON
43 36
44def rename_workspaces(ipc): 37def rename_workspaces(ipc):
45 for workspace in ipc.get_tree().workspaces(): 38 for workspace in ipc.get_tree().workspaces():
@@ -128,3 +121,4 @@ if __name__ == "__main__":
128 rename_workspaces(ipc) 121 rename_workspaces(ipc)
129 122
130 ipc.main() 123 ipc.main()
124