On Emacs 27.2 I am trying to get notifications to work on my KDE desktop. Please note that notifications work just fine on my XFCE desktop.
I can reproduce the issue easily:
ELISP> (notifications-notify)
Which produces the following error message:
Error: (dbus-error "No connection to bus" session)
I have tried to run `dbus-launch` before starting emacs but I get the same behavior.
I have tried to `(setq alert-default-style 'libnotify)` but this also does not do anything.
Any ideas on what the problem is?
EDIT:
I have partially solved the problem, though the problem is not with Emacs so this is no longer the best place for support. Anyways ...
If I run:
$ export DBUS_SESSION_BUS_ADDRESS
$ emacs
Then `(notifications-notify)` works as intended!
However I cannot figure out how to export this variable for the entire KDE session. I tried to put `export DBUS_SESSION_BUS_ADDRESS` after the `exec startplasma-x11` line in my `~/.xinitrc` but that did not work.
EDIT2:
I got it to work by launching kde with startx with the following in my `~/.xinitrc`.
exec dbus-launch --exit-with-session startplasma-x11
​