Skip to content

Improve tray icon discovery and reliability#475

Closed
romanstingler wants to merge 2 commits intoMalpenZibo:mainfrom
romanstingler:improve-tray-discovery
Closed

Improve tray icon discovery and reliability#475
romanstingler wants to merge 2 commits intoMalpenZibo:mainfrom
romanstingler:improve-tray-discovery

Conversation

@romanstingler
Copy link
Copy Markdown
Collaborator

@romanstingler romanstingler commented Feb 8, 2026

Improved tray service discovery and icon resolution

This PR fixes issues where certain apps (specifically Spotify, Telegram, and JetBrains Toolbox) weren't showing up or were missing icons in the tray because they don't follow the standard StatusNotifierItem naming conventions.

What’s changing:

  • Instead of just looking for names that explicitly say "StatusNotifierItem," the service now uses introspection. It checks common paths like /StatusNotifierItem and /MenuBar to see if they actually implement the required interface. If it looks like a tray item, we use it.
  • I added a fallback chain for icons. It now tries to pull from the DBus pixmap first, then the icon name property, and finally falls back to the app's .desktop file.
  • If one tray item fails to initialize, it won't hang the whole loop anymore. It’ll log the error and move on to the next item.

Technical Notes:

The discovery flow now scans registered DBus services and runs an introspection check for the org.kde.StatusNotifierItem interface. For icons, the priority is now:

  1. Raw pixmap data
  2. Theme lookup via icon_name
  3. ID/Title matching
  4. Desktop file lookup.

closes #437

Comment thread src/services/tray/mod.rs Outdated
Comment on lines +463 to +471
// Try each fallback candidate
let mut found_icon = None;
for candidate in fallbacks.iter() {
if let Some(icon) = get_icon_from_name(candidate) {
found_icon = Some(icon);
break;
}
}
found_icon
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code duplication

Comment thread src/services/tray/dbus.rs
.await;
} else {
// Try introspection for other services
if let Some(path_hint) = Self::find_status_notifier_path(conn, name_str).await {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could make sense to have a timeout here?

Comment thread src/services/tray/mod.rs
let item = StatusNotifierItem::new(conn, name.to_string()).await?;
let item = match StatusNotifierItem::new(conn, name.to_string()).await {
Ok(item) => item,
Err(_) => {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should place a warn?

Comment thread src/services/tray/mod.rs
}
},
State::Error => {
error!("Tray service error");
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it ok to completely remove the log here?

Comment thread src/services/tray/dbus.rs
}

impl StatusNotifierWatcher {
async fn find_status_notifier_path(conn: &Connection, name: &str) -> Option<String> {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit worried about the performance of this check, but let's try and see ifit causes a problem

@1randomguy
Copy link
Copy Markdown

Tested it, and it works well on my setup!

@romanstingler
Copy link
Copy Markdown
Collaborator Author

today and tomorrow I have not that much time, but I will try to clean up as much PRs on Thu-Sa

Add introspection-based discovery for services without StatusNotifierItem in name

Enhanced icon resolution with fallbacks using icon_name, id, and title properties

Add desktop file lookup for better icon discovery

Remove hardcoded JetBrains Toolbox path hack

Improve error handling and logging for tray initialization
@romanstingler romanstingler force-pushed the improve-tray-discovery branch from 48cdc9d to 2751d51 Compare March 6, 2026 13:45
@romanstingler
Copy link
Copy Markdown
Collaborator Author

Tested it, and it works well on my setup!

if you have the opportunity to build it on your system,
could you please try my refactor (just pushed)

git clone https://github.com/romanstingler/ashell.git
cd ashell
git checkout improve-tray-discovery

cargo b --release
./target/release/ashell

with the tray apps I tested with it works on my machine, but I want to have some more people testing it.

thanks

@1randomguy
Copy link
Copy Markdown

Tested it, and it works well on my setup!

if you have the opportunity to build it on your system, could you please try my refactor (just pushed)

git clone https://github.com/romanstingler/ashell.git
cd ashell
git checkout improve-tray-discovery

cargo b --release
./target/release/ashell

with the tray apps I tested with it works on my machine, but I want to have some more people testing it.

thanks

I tried it, but some icons are wrong. Somehow my spotify thinks it is a ghostty terminal :(
image

@romanstingler
Copy link
Copy Markdown
Collaborator Author

@1randomguy
thanks for reporting

can you please run
RUST_LOG=ashell::services::tray=debug cargo r > /tmp/log.txt
and then open you tray apps quickly - there is a lot of debugging output - and close ashell and upload that file.

@1randomguy
Copy link
Copy Markdown

tray.log

2026-03-07.11-32-09.trimmed.mp4

in this case the spotify tray icon was fine, but opening spotify broke the others 😔

@romanstingler romanstingler marked this pull request as draft March 10, 2026 23:24
@clotodex
Copy link
Copy Markdown
Collaborator

#495 built a new xdg icon discovery, and solved all icons being successfully discovered. not sure if this applies to or also works for tray, but wanted to let you know @romanstingler

@romanstingler
Copy link
Copy Markdown
Collaborator Author

yes exactly because of #495 I set this one as draft for now.
I wanted to check after the other code is ready if this one is still needed. I will close that as soon as I had time to have a look at the other code

@romanstingler romanstingler deleted the improve-tray-discovery branch March 25, 2026 20:08
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.

Tray has still some issues

4 participants