Fix desktop notifications conflict between kde plasma and dunst
Today, a short blog post mostly for myself so that I can remember in the future if that issue happen again.
Context
I’m currently using Endeavour OS with i3wm as my window manager. I say “currently”, but I have been using i3wm for more years than I can remember. On my desktop computer, even though I never use it, KDE Plasma Desktop is also installed. Main reason being that I installed it for potentially allow someone else to use this computer with a more “traditional” (understand: usable with a mouse) complete desktop environment. I thought it would maybe be useful a few time, even though it didn’t happen yet.
What I didn’t know is that it may cause issue between kde built-in notification system and dunst. Dunst is a standalone notification daemon, very useful when you use a window manager and not a desktop environment (DE). Most DE have their own implementation of a notification deamon. Kde plasma, Gnome, Cinnamon and others all do. So the solution should also apply in case of conflict with others.
Symptoms and debugging
Symptoms are easily found: when a notification is due to happen, the application that sent the notification will freeze for one minute.
An easy to confirm if the freeze is due to that particular problem is to send a test notification, eg:
notify-send "Test notification"
If it the prompt just stall and fail after a minute, you may check if you don’t have multiple desktop notification program.
You can run this command to find out:
find /usr/share/dbus-1/services/ -name '*Notif*'
Which returned:
/usr/share/dbus-1/services/org.kde.plasma.Notifications.service
/usr/share/dbus-1/services/org.x.StatusNotifierWatcher.service
And here we find the culprit!
Solution
To fix this, as explained in the Archlinux documentation, we need to override the service used and point to the service we want.
To do so, we need to create the file:
~/.local/share/dbus-1/services/org.freedesktop.Notifications.service
With the following content
[D-BUS Service]
Name=org.freedesktop.Notifications
Exec=/usr/bin/dunst
SystemdService=dunst.service
Of course, adapt if you are using another standalone tool than Dunst.
The session has to be restarted to make it work, so exit and login again and it should be fixed (and we can test using notify-send again).
Conclusion
Was a tad annoying as at first I found a workaround that involved modifying the org.kde.plasma.Notifications.service at each reboot (granted it does not happen that often, but still). So very happy to have finally fixed it correctly :-).