Wayland doesn't support Global Shortcuts and panics
I managed to get a basic environment running on NixOS (nix 2.13.6).
System info
$ nixos-version
23.05.5533.70bdadeb94ff (Stoat)
I simply put my nix-shell (see below) into the project directory and ran nix-shell.
Problem
Running bun run tauri build:
bun run tauri build
$ tauri build
Running beforeBuildCommand `mkdir -p dist`
Finished release [optimized] target(s) in 0.15s
Bundling plock_0.1.0_amd64.deb (/home/manuel/www/plock/src-tauri/target/release/bundle/deb/plock_0.1.0_amd64.deb)
Bundling plock_0.1.0_amd64.AppImage (/home/manuel/www/plock/src-tauri/target/release/bundle/appimage/plock_0.1.0_amd64.AppImage)
Error failed to bundle project: error running appimage.sh
error: script "tauri" exited with code 1 (SIGHUP)
Running bun run tauri dev:
bun run tauri dev
$ tauri dev
Running BeforeDevCommand (`mkdir -p dist`)
Info Watching /home/manuel/www/plock/src-tauri for changes...
Finished dev [unoptimized + debuginfo] target(s) in 0.16s
thread 'main' panicked at src/main.rs:142:18:
Failed to register global shortcut: GlobalShortcut(InvalidAccelerator("Unable to register global shortcut"))
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: script "tauri" exited with code 101
Example nix-shell
let
pkgs = import (fetchTarball("https://github.com/NixOS/nixpkgs/archive/057f9aecfb71c4437d2b27d3323df7f93c010b7e.tar.gz")) {};
libraries = with pkgs;[
bun
cargo
ollama
rustc
xorg.libXtst
xdotool
libayatana-appindicator
webkitgtk
gtk3
cairo
gdk-pixbuf
glib
dbus
];
packages = with pkgs; [
bun
cargo
ollama
rustc
xorg.libXtst
xdotool
libayatana-appindicator
pkg-config
dbus
glib
gtk3
libsoup
webkitgtk
appimagekit
];
in
pkgs.mkShell {
buildInputs = packages;
shellHook =
''
export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath libraries}:$LD_LIBRARY_PATH
export XDG_DATA_DIRS=${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}:${pkgs.gtk3}/share/gsettings-schemas/${pkgs.gtk3.name}:$XDG_DATA_DIRS
'';
}
@manuel-minniti
Unable to register global shortcut - can you try modifying the shortcut? make it something like Ctrl+Shift+. and Ctrl+Shift+/ instead and see if it works?
Might want to pull main first as this is way easier now with the settings.json.
attempted fix: https://github.com/jasonjmcghee/plock/commit/c12e6a15550c8ba8c2286c573593e1f84553cdd8
@manuel-minniti - lmk if fixed!
Thanks for the quick reply, I'll let you know!
Still getting the same error unfortunately.
thread 'main' panicked at src/main.rs:148:18: Failed to register global shortcut: GlobalShortcut(InvalidAccelerator("Unable to register global shortcut"))
Is there a way to get a more verbose error message?
You can run with RUST_BACKTRACE=1
Are you running Wayland?
If so... https://github.com/tauri-apps/global-hotkey/issues/28
RUST_BACKTRACE=1 did not really tell me much.
Yes, I am using Wayland and I have since upgraded NixOS to 24.05 (Uakari).
Alright. I think we'll need to figure out a workaround for Wayland... as tauri doesn't support it yet for global shortcuts and it causes a panic.
Every hotkey library I've found does not support Wayland. Also found this- relatively interesting https://gist.github.com/probonopd/9feb7c20257af5dd915e3a9f2d1f2277
Next best thing seems like manually parsing the accelerator and monitoring "pressed_keys" for the shortcut we're looking for