notify-rust
notify-rust copied to clipboard
Not working in Gnome 46 (Wayland)
Notifications are not being displayed in Gnome 46. For example, This will print the NotificationHandle
but no notification shows on the desktop:
if let Ok(handle) = Notification::new().summary("Summary").body("Body").show() {
println!("{handle:?}");
}
OKay, this seems to be an issue with Wayland. Works on XOrg.
I believe I'm seeing this issue as well on Gnome 46 (Wayland) and was not seeing it in Gnome 45 (Wayland).
Oddly, the example programs provided with notify-rust that I've tried all work. For the notification sent by the application I'm working on, the notification sound is played but no notification appears in the notification center. The notification shows up in dbus-monitor, but it looks like it's immediately closed such that it never actually appears on screen.
Messing around with notification properties, I found that if I add an .on_close
similar to the wait_for_closing
example then the notification does appear.
that seems like you have to keep the connection open then. If you don't use one of these to functions the dbus connection is tossed immediately.
Still trying to track this down, as having the notification be open relying on the application being open (to keep the dbus connection open) is less than ideal (and isn't necessary for the examples). The simplest case I've been able to reproduce with is the following: open a window with winit
's WindowBuilder::new().build(&event_loop)
after which any notification (sent via the window event loop or not) will not show up on the desktop (but is visible via dbus-monitor
).
One difference I'm seeing on dbus-monitor
, but I can't tell if it's significant, is that notifications from other applications that are visible have both a sender-pid
and x-shell-sender-pid
dictionary entry, like
dict entry(
string "sender-pid"
variant int64 1779291
)
dict entry(
string "x-shell-sender-pid"
variant uint32 1779291
)
where the notifications from notify-rust
only has a x-shell-sender-pid
entry.
Finally had some time to look into this further. I have not been able to able to find a way to get notifications to show from an event loop via XDG notifications. Adding the sender-pid
to the dict
doesn't help, nor any other way I tried to make the notifications match those sent by other applications or by utilizing libnotify
. What I found to work, is sending the notification via XDG Desktop Portal notifications. The attributes/functionality is not one-to-one with XDG notifications unfortunately, but it does function.
If it's possible to augment notify-rust
with XDG Desktop Portal notifications, would it be within the scope of the project? Not replace any existing functionality, but send portal notifications either when they are determined necessary. I'd be interested in working on that functionality, if it might have a place.
It seems the same problem in Gnome 46 (both X11 and Wayland) tauri-apps/plugins-workspace#1562
Issue appears to be tracked at the upstream repository with a potential workaround (--wait
).