mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-07-04 15:24:21 +02:00
i3-companion: simplify the way we get application icons
Just rely on the class.
This commit is contained in:
parent
333c32e7df
commit
f167cf1f64
1 changed files with 5 additions and 19 deletions
|
@ -53,6 +53,7 @@ application_icons = {
|
||||||
"signal": icon(2, ""),
|
"signal": icon(2, ""),
|
||||||
"snes9x-gtk": icon(2, ""),
|
"snes9x-gtk": icon(2, ""),
|
||||||
"spotify": icon(3, ""),
|
"spotify": icon(3, ""),
|
||||||
|
"sxiv": icon(2, ""),
|
||||||
"steam": icon(3, ""),
|
"steam": icon(3, ""),
|
||||||
"vbeterm": icon(2, ""),
|
"vbeterm": icon(2, ""),
|
||||||
"zathura": icon(2, ""),
|
"zathura": icon(2, ""),
|
||||||
|
@ -274,24 +275,14 @@ async def workspace_rename(i3, event):
|
||||||
workspaces = tree.workspaces()
|
workspaces = tree.workspaces()
|
||||||
commands = []
|
commands = []
|
||||||
|
|
||||||
def application_icon(window):
|
|
||||||
"""Get application icon for a window."""
|
|
||||||
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(rf"^{k}\b", name, re.IGNORECASE):
|
|
||||||
logger.debug("in %s, found '%s', matching %s", attr, name, k)
|
|
||||||
return v
|
|
||||||
return application_icons_nomatch
|
|
||||||
|
|
||||||
for workspace in workspaces:
|
for workspace in workspaces:
|
||||||
icons = set()
|
icons = set()
|
||||||
for window in workspace.leaves():
|
for window in workspace.leaves():
|
||||||
if window.sticky:
|
if window.sticky:
|
||||||
continue
|
continue
|
||||||
icon = application_icon(window)
|
icon = application_icons.get(
|
||||||
|
window.window_class.lower(), application_icons_nomatch
|
||||||
|
)
|
||||||
if icon is not None:
|
if icon is not None:
|
||||||
icons.add(icon)
|
icons.add(icon)
|
||||||
if any([i not in application_icons_alone for i in icons]):
|
if any([i not in application_icons_alone for i in icons]):
|
||||||
|
@ -351,12 +342,7 @@ async def worksplace_exclusive(i3, event):
|
||||||
|
|
||||||
# Get the window workspace. From an event, w.workspace() is None,
|
# Get the window workspace. From an event, w.workspace() is None,
|
||||||
# so search it in the tree.
|
# so search it in the tree.
|
||||||
current_workspace = next(
|
current_workspace = tree.find_by_id(w.id).workspace()
|
||||||
(ow.workspace().num for ow in tree.leaves() if w.id == ow.id), None
|
|
||||||
)
|
|
||||||
if not current_workspace:
|
|
||||||
logger.info(f"cannot get workspace for {w.window_class}")
|
|
||||||
return
|
|
||||||
|
|
||||||
# Get the list of workspaces with an exclusive app, excluding the
|
# Get the list of workspaces with an exclusive app, excluding the
|
||||||
# current window and windows of the same class.
|
# current window and windows of the same class.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue