Skip to content

Accurately associate snap processes with their desktop app#654

Merged
nokyan merged 1 commit intonokyan:mainfrom
aleasto:snap-association
Apr 2, 2026
Merged

Accurately associate snap processes with their desktop app#654
nokyan merged 1 commit intonokyan:mainfrom
aleasto:snap-association

Conversation

@aleasto
Copy link
Copy Markdown
Contributor

@aleasto aleasto commented Mar 28, 2026

  • Do not use X-SnapInstanceName as app id, it's not appropriate; instead, use the stripped desktop file name.
  • Parse the snap process cgroup according to the snapd convention
  • Use the cgroup to identify snap-name and snap-app-name (one snap may provide multiple apps)
  • Use snap-name and snap-app-name to query snapd over its REST API and get the desktop file associated with it.
  • In case of failure, fallback to the most common case: {snap-name}_{snap-app-name}

Because calling the REST API is async IO, we keep track of in-flight requests as futures and check their status at every refresh().

Closes: #599

@aleasto aleasto force-pushed the snap-association branch 2 times, most recently from be80441 to b9ca27a Compare March 28, 2026 00:29
@aleasto
Copy link
Copy Markdown
Contributor Author

aleasto commented Mar 28, 2026

Hopefully one day we won't have to do IPC to find about the snap desktop id, but that day is not today :(

@nokyan
Copy link
Copy Markdown
Owner

nokyan commented Mar 28, 2026

Hi, thanks a lot for your PR. I'll take a proper look at it tomorrow. :)

@aleasto aleasto force-pushed the snap-association branch 2 times, most recently from b29c614 to 8ef0e10 Compare March 29, 2026 08:39
@nokyan
Copy link
Copy Markdown
Owner

nokyan commented Mar 29, 2026

I don't see any issues now, though I can't test the snap part on my machine because I don't use snap. Within the next few days, I'll get an Ubuntu VM running and do some further testing on that.

@nokyan
Copy link
Copy Markdown
Owner

nokyan commented Apr 1, 2026

Hi, I tested your changes, snaps are detected more accurately, though I'm seeing in the logs that the intended way basically never seems to work? I'm on a somewhat fresh Ubuntu 24.04 install using Flatpak's build system.

 DEBUG resources::utils::snapd   > snapd request for firefox failed: Could not connect: No such file or directory
 DEBUG resources::utils::snapd   > snapd request for snap-store failed: Could not connect: No such file or directory
 DEBUG resources::utils::snapd   > snapd request for chromium failed: Could not connect: No such file or directory
 DEBUG resources::utils::snapd   > snapd request for gthumb-unofficial failed: Could not connect: No such file or directory
 DEBUG resources::utils::app     > Associating snap process 25807 (chromium.chromium) with app "chromium_chromium" via cgroup fallback
 DEBUG resources::utils::app     > Associating deferred process 25807 with app Some("chromium_chromium")
 DEBUG resources::utils::app     > Associating snap process 3734 (firefox.firefox) with app "firefox_firefox" via cgroup fallback
 DEBUG resources::utils::app     > Associating deferred process 3734 with app Some("firefox_firefox")
 DEBUG resources::utils::app     > Associating snap process 3943 (firefox.firefox) with app "firefox_firefox" via cgroup fallback
 DEBUG resources::utils::app     > Associating deferred process 3943 with app Some("firefox_firefox")
 DEBUG resources::utils::app     > Associating snap process 25806 (chromium.chromium) with app "chromium_chromium" via cgroup fallback
 DEBUG resources::utils::app     > Associating deferred process 25806 with app Some("chromium_chromium")
 DEBUG resources::utils::app     > Associating snap process 3495 (firefox.firefox) with app "firefox_firefox" via cgroup fallback
 DEBUG resources::utils::app     > Associating deferred process 3495 with app Some("firefox_firefox")
 DEBUG resources::utils::app     > Associating snap process 17694 (chromium.chromium) with app "chromium_chromium" via cgroup fallback
 DEBUG resources::utils::app     > Associating deferred process 17694 with app Some("chromium_chromium")
 DEBUG resources::utils::app     > Associating snap process 17314 (chromium.chromium) with app "chromium_chromium" via cgroup fallback
 DEBUG resources::utils::app     > Associating deferred process 17314 with app Some("chromium_chromium")
 DEBUG resources::utils::app     > Associating snap process 17559 (chromium.chromium) with app "chromium_chromium" via cgroup fallback
 DEBUG resources::utils::app     > Associating deferred process 17559 with app Some("chromium_chromium")
 DEBUG resources::utils::app     > Associating snap process 17756 (chromium.chromium) with app "chromium_chromium" via cgroup fallback
 DEBUG resources::utils::app     > Associating deferred process 17756 with app Some("chromium_chromium")
 DEBUG resources::utils::app     > Associating snap process 26362 (gthumb-unofficial.gthumb) with app "gthumb-unofficial_gthumb" via cgroup fallback
 DEBUG resources::utils::app     > Associating deferred process 26362 with app Some("gthumb-unofficial_gthumb")
 DEBUG resources::utils::app     > Associating snap process 17553 (chromium.chromium) with app "chromium_chromium" via cgroup fallback
 DEBUG resources::utils::app     > Associating deferred process 17553 with app Some("chromium_chromium")
 DEBUG resources::utils::app     > Associating snap process 17610 (chromium.chromium) with app "chromium_chromium" via cgroup fallback
 DEBUG resources::utils::app     > Associating deferred process 17610 with app Some("chromium_chromium")
 DEBUG resources::utils::app     > Associating snap process 3978 (firefox.firefox) with app "firefox_firefox" via cgroup fallback
 DEBUG resources::utils::app     > Associating deferred process 3978 with app Some("firefox_firefox")
 DEBUG resources::utils::app     > Associating snap process 3948 (firefox.firefox) with app "firefox_firefox" via cgroup fallback
 DEBUG resources::utils::app     > Associating deferred process 3948 with app Some("firefox_firefox")
 DEBUG resources::utils::app     > Associating snap process 17560 (chromium.chromium) with app "chromium_chromium" via cgroup fallback
 DEBUG resources::utils::app     > Associating deferred process 17560 with app Some("chromium_chromium")
 DEBUG resources::utils::app     > Associating snap process 17613 (chromium.chromium) with app "chromium_chromium" via cgroup fallback
 DEBUG resources::utils::app     > Associating deferred process 17613 with app Some("chromium_chromium")
 DEBUG resources::utils::app     > Associating snap process 3223 (firefox.firefox) with app "firefox_firefox" via cgroup fallback
 DEBUG resources::utils::app     > Associating deferred process 3223 with app Some("firefox_firefox")
 DEBUG resources::utils::app     > Associating snap process 4229 (firefox.firefox) with app "firefox_firefox" via cgroup fallback
 DEBUG resources::utils::app     > Associating deferred process 4229 with app Some("firefox_firefox")
 DEBUG resources::utils::app     > Associating snap process 14712 (snap-store.snap-store) with app "snap-store_snap-store" via cgroup fallback
 DEBUG resources::utils::app     > Associating deferred process 14712 with app Some("snap-store_snap-store")
 DEBUG resources::utils::app     > Associating snap process 3935 (firefox.firefox) with app "firefox_firefox" via cgroup fallback
 DEBUG resources::utils::app     > Associating deferred process 3935 with app Some("firefox_firefox")
 DEBUG resources::utils::app     > Associating snap process 17555 (chromium.chromium) with app "chromium_chromium" via cgroup fallback
 DEBUG resources::utils::app     > Associating deferred process 17555 with app Some("chromium_chromium")
 DEBUG resources::utils::app     > Associating snap process 17562 (chromium.chromium) with app "chromium_chromium" via cgroup fallback
 DEBUG resources::utils::app     > Associating deferred process 17562 with app Some("chromium_chromium")
 DEBUG resources::utils::app     > Associating snap process 17609 (chromium.chromium) with app "chromium_chromium" via cgroup fallback
 DEBUG resources::utils::app     > Associating deferred process 17609 with app Some("chromium_chromium")
 DEBUG resources::utils::app     > Associating snap process 3514 (firefox.firefox) with app "firefox_firefox" via cgroup fallback
 DEBUG resources::utils::app     > Associating deferred process 3514 with app Some("firefox_firefox")
 DEBUG resources::utils::app     > Associating snap process 4190 (firefox.firefox) with app "firefox_firefox" via cgroup fallback
 DEBUG resources::utils::app     > Associating deferred process 4190 with app Some("firefox_firefox")
 DEBUG resources::utils::app     > Associating snap process 17673 (chromium.chromium) with app "chromium_chromium" via cgroup fallback
 DEBUG resources::utils::app     > Associating deferred process 17673 with app Some("chromium_chromium")

@nokyan
Copy link
Copy Markdown
Owner

nokyan commented Apr 1, 2026

Seems to be a Flatpak thing as it works fine on native builds, I'll figure this out later. One small thing remains though, the process list isn't updated and all the snaps still have their generic icons (Chromium and Firefox being installed as snaps):
image

Adding self.set_icon(&process.icon); somewhere in the function resources::ui::pages::processes::process_entry::ProcessEntry::update() does fix the issue though. After that, I think we can get this merged. :)

* Do not use X-SnapInstanceName as app id, it's not appropriate; instead, use
  the stripped desktop file name.
* Parse the snap process cgroup according to the snapd convention
* Use the cgroup to identify snap-name and snap-app-name (one snap may provide
  multiple apps)
* Use snap-name and snap-app-name to query snapd over its REST API and get
  the desktop file associated with it.
* In case of failure, fallback to the most common case:
  "{snap-name}_{snap-app-name}"

Because calling the REST API is async IO, we keep track of in-flight requests
as futures and check their status at every refresh().

Closes: nokyan#599
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@aleasto aleasto force-pushed the snap-association branch from 39beeca to 9e62463 Compare April 1, 2026 19:33
@nokyan nokyan merged commit 52e8e63 into nokyan:main Apr 2, 2026
1 check passed
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.

Chromium Snap not detected

2 participants