diff options
| author | Arpit Chakladar <arpitchakladar+git@gmail.com> | 2026-08-27 00:48:09 +0530 |
|---|---|---|
| committer | Arpit Chakladar <arpitchakladar+git@gmail.com> | 2026-08-29 03:50:30 +0530 |
| commit | 26022cdaba2e3e542adcfd9570de3b04b6bc8541 (patch) | |
| tree | 77045480173725f8082e6f6e19cf8457569c8865 | |
| parent | c306d53594a6cefc2ecc39dd8d29f9edf1b8ed77 (diff) | |
| download | home-manager-config-26022cdaba2e3e542adcfd9570de3b04b6bc8541.tar.gz home-manager-config-26022cdaba2e3e542adcfd9570de3b04b6bc8541.zip | |
desktop: added an actual unknown window icon, fixed the scripts crashing
- using a question mark svg as the icon for unknown windows
- the activate-windows and workspaces scripts encountered crashes when
trying to get the icon, fixed it
| -rw-r--r-- | assets/icons/unknown.svg | 3 | ||||
| -rw-r--r-- | modules/desktop/eww/activate-windows.py | 22 | ||||
| -rw-r--r-- | modules/desktop/eww/workspaces.py | 11 | ||||
| -rw-r--r-- | modules/desktop/eww/yuck.nix | 4 |
4 files changed, 25 insertions, 15 deletions
diff --git a/assets/icons/unknown.svg b/assets/icons/unknown.svg new file mode 100644 index 0000000..3b3d2ce --- /dev/null +++ b/assets/icons/unknown.svg @@ -0,0 +1,3 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none"> + <path d="M8 3.5C6.34315 3.5 5 4.84315 5 6.5C5 7.05228 5.44772 7.5 6 7.5C6.55228 7.5 7 7.05228 7 6.5C7 5.94772 7.44772 5.5 8 5.5C8.55228 5.5 9 5.94772 9 6.5C9 7.05228 8.55228 7.5 8 7.5C7.17157 7.5 6.5 8.17157 6.5 9V10C6.5 10.5523 6.94772 11 7.5 11C8.05228 11 8.5 10.5523 8.5 10V9.85C9.97056 9.4005 11 8.0772 11 6.5C11 4.84315 9.65685 3.5 8 3.5ZM8.5 13C8.5 13.5523 8.05228 14 7.5 14C6.94772 14 6.5 13.5523 6.5 13C6.5 12.4477 6.94772 12 7.5 12C8.05228 12 8.5 12.4477 8.5 13Z" fill="#FFFFFF"/> +</svg> diff --git a/modules/desktop/eww/activate-windows.py b/modules/desktop/eww/activate-windows.py index 5773d64..f07b6a2 100644 --- a/modules/desktop/eww/activate-windows.py +++ b/modules/desktop/eww/activate-windows.py @@ -12,16 +12,22 @@ icon_theme = Gtk.IconTheme.get_default() _icon_cache: dict[str, str] = {} +def try_desktop_app_info(desktop_id: str): + try: + return Gio.DesktopAppInfo.new(desktop_id) + except TypeError: + return None + + def resolve_icon_path(app_id: str) -> str: if not app_id: return "" if app_id in _icon_cache: return _icon_cache[app_id] - app_info = Gio.DesktopAppInfo.new(f"{app_id}.desktop") \ - or Gio.DesktopAppInfo.new(f"{app_id.lower()}.desktop") + app_info = try_desktop_app_info(f"{app_id}.desktop") \ + or try_desktop_app_info(f"{app_id.lower()}.desktop") - # fall back: scan installed .desktop files for a matching StartupWMClass if app_info is None: for info in Gio.AppInfo.get_all(): if isinstance(info, Gio.DesktopAppInfo): @@ -33,17 +39,11 @@ def resolve_icon_path(app_id: str) -> str: icon_path = "" gicon = app_info.get_icon() if app_info else None if gicon is not None: - lookup = icon_theme.lookup_by_gicon(gicon, - 32, - Gtk.IconLookupFlags.FORCE_SIZE) + lookup = icon_theme.lookup_by_gicon(gicon, 24, Gtk.IconLookupFlags.FORCE_SIZE) if lookup: icon_path = lookup.get_filename() or "" - if not icon_path: - # last resort: treat app_id itself as an icon-theme name - lookup = icon_theme.lookup_icon(app_id, - 32, - Gtk.IconLookupFlags.FORCE_SIZE) + lookup = icon_theme.lookup_icon(app_id, 24, Gtk.IconLookupFlags.FORCE_SIZE) if lookup: icon_path = lookup.get_filename() or "" diff --git a/modules/desktop/eww/workspaces.py b/modules/desktop/eww/workspaces.py index b8fae1b..d8e774b 100644 --- a/modules/desktop/eww/workspaces.py +++ b/modules/desktop/eww/workspaces.py @@ -11,14 +11,21 @@ icon_theme = Gtk.IconTheme.get_default() _icon_cache: dict[str, str] = {} +def try_desktop_app_info(desktop_id: str): + try: + return Gio.DesktopAppInfo.new(desktop_id) + except TypeError: + return None + + def resolve_icon_path(app_id: str) -> str: if not app_id: return "" if app_id in _icon_cache: return _icon_cache[app_id] - app_info = Gio.DesktopAppInfo.new(f"{app_id}.desktop") \ - or Gio.DesktopAppInfo.new(f"{app_id.lower()}.desktop") + app_info = try_desktop_app_info(f"{app_id}.desktop") \ + or try_desktop_app_info(f"{app_id.lower()}.desktop") if app_info is None: for info in Gio.AppInfo.get_all(): diff --git a/modules/desktop/eww/yuck.nix b/modules/desktop/eww/yuck.nix index 0654d9a..228db86 100644 --- a/modules/desktop/eww/yuck.nix +++ b/modules/desktop/eww/yuck.nix @@ -101,7 +101,7 @@ (box :class "workspace-button ''${ws.is_active ? 'active' : '''}" :halign "fill" (overlay :halign "fill" (image :class "workspace-icon" - :path "''${ws.icon != ''' ? ws.icon : '${../../../assets/icons/obs.svg}'}" + :path "''${ws.icon != ''' ? ws.icon : '${../../../assets/icons/unknown.svg}'}" :image-width 20 :image-height 20) (label :class "workspace-idx" :text "''${ws.idx}" :halign "end" :valign "end"))))))) @@ -114,7 +114,7 @@ :halign "fill" :tooltip "''${w.app_id}: ''${w.title != ''' ? ' ' : '''}''${w.title}" (box :halign "fill" :class "window-button ''${w.is_focused ? 'focused' : '''}" - (image :class "window-icon" :path "''${w.icon != ''' ? w.icon : '${../../../assets/icons/obs.svg}'}" :image-width 20 :image-height 20)))))) + (image :class "window-icon" :path "''${w.icon != ''' ? w.icon : '${../../../assets/icons/unknown.svg}'}" :image-width 20 :image-height 20)))))) ''; }; } |
