tauri-apps / tauri-apps/plugins-workspace

tauri_plugin_global_shortcut callback doesn't work in wayland

Open
#3,267 2 comments 0 reactions 0 assignees View on GitHub
platform: linux plugin: global-shortcut status: upstream type: bug
Dominant language
Rust
Stars
1.8k
Forks
602
Avg merge
4d 14h
Merged PRs (30d)
9

Description

### 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](https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/global-shortcut) in global shortcut
lib.rs
```rust
#[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
```rust
[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
``` rust
{
"$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"
]
}
```

```bash
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

```text
[✔] 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

```text
No error
```

### Additional context

There is an another example using this plugin.
It works in Windows ([code](https://github.com/liangruogu/Trilo)):
![Image](https://github.com/user-attachments/assets/2c60b648-2860-4c78-b763-b902731da1de)
However, in fedora shortcut also registered successfully but the callback didn't work at all.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.