mirror of
https://github.com/swaywm/sway.git
synced 2024-12-28 16:06:37 +01:00
refactor icon_for_window function
This commit is contained in:
parent
61df9eb62a
commit
1a0f86be4e
1 changed files with 11 additions and 17 deletions
|
@ -22,24 +22,17 @@ DEFAULT_ICON = ""
|
||||||
|
|
||||||
|
|
||||||
def icon_for_window(window):
|
def icon_for_window(window):
|
||||||
app_id = window.app_id
|
name = None
|
||||||
if app_id is not None and len(app_id) > 0:
|
if window.app_id is not None and len(window.app_id) > 0:
|
||||||
app_id = app_id.lower()
|
name = window.app_id.lower()
|
||||||
if app_id in WINDOW_ICONS:
|
elif window.window_class is not None and len(window.window_class) > 0:
|
||||||
return WINDOW_ICONS[app_id]
|
name = window.window_class.lower()
|
||||||
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
|
|
||||||
|
|
||||||
|
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):
|
def rename_workspaces(ipc):
|
||||||
for workspace in ipc.get_tree().workspaces():
|
for workspace in ipc.get_tree().workspaces():
|
||||||
|
@ -128,3 +121,4 @@ if __name__ == "__main__":
|
||||||
rename_workspaces(ipc)
|
rename_workspaces(ipc)
|
||||||
|
|
||||||
ipc.main()
|
ipc.main()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue