I'm facing the same issue and this seems like a tough nut to crack.
One workaround I came across is using sudo
to run the script that needs root privileges (and is supposed to send notifications). This provides access to environment variables SUDO_USER
and SUDO_UID
.
As the user running the Wayland session, run:
$ sudo notify-test.sh --app-name="Script" "Hello world!"
Contents of notify-test.sh
:
#!/bin/bash
sudo -u ${SUDO_USER} DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/${SUDO_UID}/bus notify-send "$@"
Tested successfully on KDE Plasma running a Wayland session.