fix: tray icons duplicating and disappearing after session restore#2117
Closed
Dimariqe wants to merge 1 commit intoAvengeMedia:masterfrom
Closed
fix: tray icons duplicating and disappearing after session restore#2117Dimariqe wants to merge 1 commit intoAvengeMedia:masterfrom
Dimariqe wants to merge 1 commit intoAvengeMedia:masterfrom
Conversation
Add TrayRecoveryService singleton that re-registers lost tray icons after resume from suspend via a bash DBus scan. The service resolves every registered SNI item (both well-known names and :1.xxx connection IDs) to a canonical connection ID, building a unified REGISTERED_CONN_IDS set before either scan section runs. This prevents duplicates in both directions: - If an app registered via well-known name, the connection-ID section skips its :1.xxx entry. - If an app registered via connection ID, the well-known-name section skips its well-known name (checked through REGISTERED_CONN_IDS). - After successfully registering via well-known name, REGISTERED_CONN_IDS is updated immediately so the connection-ID section won't probe the same app in the same run. A single busctl snapshot (BUSCTL_OUT) is reused across both sections, replacing redundant dbus-send ListNames calls. The SNI Id dedup check inside the connection-ID subshells is now case-insensitive (-i flag) as a secondary fallback.
Collaborator
|
This is nice, though I think we could just integrate it into DMS server, and not need any additional QML for it. That might be a better approach since it's already hooked in to everything. |
Author
|
I'll be back with a Go implementation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
After resume from suspend (or forced session restore via Hyprland),
some tray icons disappear. Apps that don't detect a StatusNotifierWatcher
restart don't re-register their SNI items, leaving the tray empty.
Additionally, a
TrayRecoveryServicethat scans DBus for unregisteredSNI items after resume could produce duplicate icons because apps
may register their SNI item either via their well-known name
(
com.example.AppName/StatusNotifierItem) or via their connection ID(
:1.49/StatusNotifierItem), and the old dedup logic didn't accountfor this equivalence.
Root causes
Directional blind spot — the well-known name scan and the
connection-ID scan each only checked their own form against the
registered items list. If an app registered as
:1.49, thewell-known-name section would still try to register
com.example.AppName, and vice versa.Case-sensitive SNI Id comparison — some apps report their SNI
Idproperty in a different case than their well-known name(e.g.
"exampleapp"vs"com.example.ExampleApp/...").grep -qFnever matched, so the fallback dedup check was silentlyskipped every time.
Solution
Add
TrayRecoveryService— a singleton that fires 3 seconds afterresume and scans DBus for SNI items that need re-registration.
Key design decisions:
REGISTERED_CONN_IDSset built upfront by resolvingevery currently registered item (regardless of whether it was
registered as a well-known name or a connection ID) to its canonical
:1.xxxconnection ID. This is the single source of truth used byboth scan sections.
REGISTERED_CONN_IDSviathe name's connection ID before probing — skips apps already covered
by a connection-ID registration.
REGISTERED_CONN_IDSisupdated immediately so the connection-ID section running next won't
probe the same app again in the same recovery pass.
REGISTERED_CONN_IDSas its primarygate, with a case-insensitive SNI
Idstring match as a secondaryfallback inside each parallel subshell.
busctlsnapshot (BUSCTL_OUT) is taken once and reusedacross both sections, replacing two redundant
dbus-send ListNamescalls.