Skip to content

tauri_plugin_global_shortcut callback doesn't work in wayland #3267

@liangruogu

Description

@liangruogu

Describe the bug

tauri_plugin_global_shortcut plugin's with_handler callback function didn't work in wayland

DE: wayland gnome (gnome-shell 48.7) Fedora (42)
rustc 1.93.0 (254b59607 2026-01-19)
bun: 1.2.15

Reproduction

Example in global shortcut
lib.rs

#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
    tauri::Builder::default()
        .setup(|app| {
            #[cfg(desktop)]
            {
                use tauri::Emitter;
                use tauri_plugin_global_shortcut::{Code, Modifiers, ShortcutState};

                app.handle().plugin(
                    tauri_plugin_global_shortcut::Builder::new()
                        .with_shortcuts(["ctrl+d", "alt+space"])?
                        .with_handler(|app, shortcut, event| {
                            println!("Callback function");
                            if event.state == ShortcutState::Pressed {
                                if shortcut.matches(Modifiers::CONTROL, Code::KeyD) {
                                    let _ = app.emit("shortcut-event", "Ctrl+D triggered");
                                }
                                if shortcut.matches(Modifiers::ALT, Code::Space) {
                                    let _ = app.emit("shortcut-event", "Alt+Space triggered");
                                }
                            }
                        })
                        .build(),
                )?;
            }

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

Cargo.toml

[package]
name = "test-plugin"
version = "0.1.0"
description = "A Tauri App"
authors = ["you"]
edition = "2021"

[lib]
name = "test_plugin_lib"
crate-type = ["staticlib", "cdylib", "rlib"]

[build-dependencies]
tauri-build = { version = "2", features = [] }

[dependencies]
tauri = { version = "2", features = [] }
tauri-plugin-opener = "2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"

[target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies]
tauri-plugin-global-shortcut = "2.0.0"

default.json

{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "default",
  "description": "Capability for the main window",
  "windows": ["main"],
  "permissions": [
    "core:default",
    "opener:default",
    "global-shortcut:allow-is-registered",
    "global-shortcut:allow-register",
    "global-shortcut:allow-unregister"
  ]
}
bun install && bun install  @tauri-apps/plugin-global-shortcut && bun run tauri dev

Press the shortcut (ctrl+d or alt+space by default)

Expected behavior

Callback function work: print log message in the terminal

Full tauri info output

[✔] Environment
    - OS: Fedora 42.0.0 x86_64 (X64) (gnome on wayland)
    ✔ webkit2gtk-4.1: 2.50.4
    ✔ rsvg2: 2.60.0
    ✔ rustc: 1.93.0 (254b59607 2026-01-19)
    ✔ cargo: 1.93.0 (083ac5135 2025-12-15)
    ✔ rustup: 1.28.2 (e4f3ad6f8 2025-04-28)
    ✔ Rust toolchain: stable-x86_64-unknown-linux-gnu (default)
    - node: 22.19.0
    - pnpm: 10.15.0
    - yarn: 1.22.22
    - npm: 10.9.3
    - bun: 1.2.15

[-] Packages
    - tauri 🦀: 2.10.2
    - tauri-build 🦀: 2.5.5
    - wry 🦀: 0.54.1
    - tao 🦀: 0.34.5
    - @tauri-apps/api  ⱼₛ: 2.10.1
    - @tauri-apps/cli  ⱼₛ: 2.10.0

[-] Plugins
    - tauri-plugin-global-shortcut 🦀: 2.3.1
    - @tauri-apps/plugin-global-shortcut  ⱼₛ: 2.3.1
    - tauri-plugin-opener 🦀: 2.5.3
    - @tauri-apps/plugin-opener  ⱼₛ: 2.5.3

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../build
    - devUrl: http://localhost:1420/
    - framework: Svelte
    - bundler: Vite

Stack trace

No error

Additional context

There is an another example using this plugin.
It works in Windows (code):
Image
However, in fedora shortcut also registered successfully but the callback didn't work at all.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions