Skip to content

Linux: show taskbar unread badge on KDE / non-Unity desktops#2756

Open
WebDevBar wants to merge 3 commits into
Foundry376:masterfrom
WebDevBar:feat/kde-launcher-badge
Open

Linux: show taskbar unread badge on KDE / non-Unity desktops#2756
WebDevBar wants to merge 3 commits into
Foundry376:masterfrom
WebDevBar:feat/kde-launcher-badge

Conversation

@WebDevBar

Copy link
Copy Markdown

Problem

On Linux the unread badge is set via app.setBadgeCount(), which relies on libunity. libunity ships on Ubuntu/Unity but not on Fedora/KDE/openSUSE, so the taskbar badge silently does nothing there (see #1890, #1042, and others).

Fix

In the existing set-badge-value main-process handler, on Linux also emit the raw com.canonical.Unity.LauncherEntry Update signal over the session bus (via the pure-JS dbus-next), keyed to application://Mailspring.desktop. This is the same mechanism KMail/Geary use natively and works on KDE/GNOME/etc. without libunity.

  • Safe no-op when there is no session bus.
  • The async bus error event is handled, so a bus failure never crashes the app.
  • macOS (app.dock.setBadge) and Windows overlay paths are untouched.

Notes

  • New dependency: dbus-next (pure JS, no native build).
  • Unit + integration specs added: app/spec/linux-launcher-entry-spec.ts.
  • Verified on Fedora KDE Plasma 6.7: the unread badge renders on the Mailspring taskbar icon, and dbus-monitor shows the Update signal carrying the correct count / count-visible.

Addresses the KDE/non-Unity half of #1890 and #1042.

@bengotow

Copy link
Copy Markdown
Collaborator

Ahh this is super interesting, thanks for contributing this fix!

I had Claude go off and read a bunch of forums, etc. to make sure this is a standard approach and it found the same mechanism in use in KMail, Geary, and Qt Creator, so we're definitely good there. Kind of surprising this hasn't been merged into Electron upstream, I had no idea setBadgeCount had such limited support on Linux.

It looks like the dbus-next package has some stale dependencies and is going on ~5 years unmaintained. There are known vulnerability reports in a couple of it's old deps and I'm trying to be a bit more hawkish about node packages given the recent ecosystem security incidents.

I think we can pull in a single utility from dbus-next (and tweak it to use native Buffers and native usocket / BigInt, since we have modern Node!) since it's MIT licensed. I had Claude do it and compare that the output is bye-identical to dbus-next - could you drop this file in and see if it works for you in place of that dependency?

linux-launcher-entry.ts

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.

2 participants