plugins-workspace icon indicating copy to clipboard operation
plugins-workspace copied to clipboard

[bug] no notifications in gnome 46+ (eg fedora 41 and ubuntu 24.04)

Open giovannifranco1 opened this issue 11 months ago • 5 comments

I'm experiencing an issue where the plugin does not work on Fedora 41. The system is properly set up with GTK, and all dependencies seem to be in place. However, when I try to use the plugin, nothing happens—there are no logs or error messages to help diagnose the issue.

  • Node: v20
  • Gnome 47
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
    tauri::Builder::default()
        .plugin(tauri_plugin_notification::init())
        .plugin(tauri_plugin_opener::init())
        .invoke_handler(tauri::generate_handler![open, notification])
        .setup(|app| {
            println!("setup");

            use tauri_plugin_notification::NotificationExt;
            app.notification()
                .builder()
                .title("Tauri")
                .body("Tauri is awesome")
                .show()
                .unwrap();

            Ok(())
        })
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

Permissions:

"permissions": [
    "core:default",
    "opener:default",
    "core:menu:default",
    "core:window:allow-minimize",
    "core:window:allow-maximize",
    "core:window:allow-close",
    "core:window:allow-unmaximize",
    "core:window:allow-show",
    "notification:default",
    "notification:allow-notify",
    "notification:allow-check-permissions",
    "notification:allow-show",
    "notification:allow-batch"
  ]

giovannifranco1 avatar Mar 24 '25 17:03 giovannifranco1

I have the same issue on my Ubuntu 24.04, no matter if it's Wayland or X11.

Actually it will pop up and close immediately, so it looks like nothing happened. I suspect it is because the notification handler being dropped after show() will also close the notification as well.

pewsheen avatar Mar 25 '25 06:03 pewsheen

It's really strange, especially because if you check outside the scope of tauri::Builder(), the notify-rust library works normally.

giovannifranco1 avatar Mar 27 '25 12:03 giovannifranco1

A workaround I use in my side project is spawning a new thread and showing the notification with an empty .on_close()

pewsheen avatar Apr 01 '25 02:04 pewsheen

Seems like downstream issue with gnome because there is already issue in notify-rust https://github.com/hoodie/notify-rust/issues/218 and in libnotify gitlab.gnome.org/GNOME/libnotify/-/issues/41

jaca1119 avatar Apr 20 '25 09:04 jaca1119

Alternative Solution: Using System notify-send Command

I've successfully resolved the GNOME 46+ notification issue by bypassing the Tauri plugin and using the system notify-send command directly. This approach works reliably across all Linux desktop distributions,but may not safe?.

Solution Code

#[command]
pub fn send_notification(_app: AppHandle, title: String, body: String) -> Result<(), String> {
    thread::spawn(move || {
        let result = Command::new("notify-send")
            .args(["--app-name=wngtools", "--urgency=normal", "--expire-time=5000",
                   "--hint=string:sound-name:message-new-instant", &title, &body])
            .output();

        match result {
            Ok(output) if output.status.success() => {
                println!("✅ Notification sent: {}", title);
            }
            _ => {
                eprintln!("❌ Notification failed for: {}", title);
            }
        }
    });
    Ok(())
}

xingwangzhe avatar Aug 29 '25 00:08 xingwangzhe