Skip to content

fix(tray): resolve icons advertised with custom theme path#1490

Open
pedroboussiengui wants to merge 1 commit into
caelestia-dots:mainfrom
pedroboussiengui:fix/tray-icon-custom-theme-path
Open

fix(tray): resolve icons advertised with custom theme path#1490
pedroboussiengui wants to merge 1 commit into
caelestia-dots:mainfrom
pedroboussiengui:fix/tray-icon-custom-theme-path

Conversation

@pedroboussiengui

Copy link
Copy Markdown

Problem

Tray icons from apps that ship their own icon theme (Dropbox, KeePassXC, and others) never render — only the missing-icon fallback shows up. The bar still receives the item (clicks and the menu work), but the pixmap is blank.

Root cause

Such apps expose their icon over StatusNotifierItem as:

image://icon/<name>?path=/absolute/theme/root

For example, Dropbox sends:

image://icon/dropboxstatus-idle?path=/home/<user>/.dropbox-dist/dropbox-lnx.x86_64-XXXXXXX/images

The advertised path is the theme root (containing hicolor/<size>/<category>/...), not the leaf directory of the file. The previous Icons.getTrayIcon split the URL and built file://<path>/<name> directly — no extension, wrong directory — so IconImage could never load it.

Fix

  • Replace getTrayIcon with getTrayIconCandidates(id, icon) which returns an ordered list of candidate URLs:
    1. iconSubs overrides (unchanged behavior).
    2. The raw path root, with .png / .svg.
    3. Standard freedesktop layout under the path: [hicolor|""]/<size>/<category>/<name>.<ext> across common sizes (16x16scalable) and categories (status, apps, actions, …).
  • TrayItem consumes the list and walks to the next candidate on Image.Error, stopping at the first that loads.

For icons without ?path= (most apps using the system theme, or image://qspixmap/... from IconPixmap), the candidate list is just [icon], so behavior is unchanged.

Files

  • utils/Icons.qml: introduces getTrayIconCandidates.
  • modules/bar/components/TrayItem.qml: iterates candidates on load failure.

Testing

  • Dropbox 252.4.3485 on Hyprland: tray icon now renders correctly (resolves to …/images/hicolor/16x16/status/dropboxstatus-idle.png).
  • Regular apps using image://icon/<name> (Arch-Update, etc.): unchanged.
  • image://qspixmap/... from apps that embed pixmaps via D-Bus: unchanged.
  • iconSubs substitutions in bar.tray.iconSubs: still applied first.

Notes

The freedesktop spec calls for a full theme lookup using index.theme, but doing that in pure QML would mean parsing the theme file and walking directories. The candidate-list approach covers every real-world layout I could find (Dropbox, KeePassXC, Discord-style trays) with negligible cost — IconImage only requests the next URL when the previous one errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant