Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wayland doesn't support Global Shortcuts and panics #3

Open
manuel-minniti opened this issue Jan 22, 2024 · 8 comments
Open

Wayland doesn't support Global Shortcuts and panics #3

manuel-minniti opened this issue Jan 22, 2024 · 8 comments

Comments

@manuel-minniti
Copy link

manuel-minniti commented Jan 22, 2024

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
    '';
}
@jasonjmcghee
Copy link
Owner

jasonjmcghee commented Jan 22, 2024

@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.

@jasonjmcghee
Copy link
Owner

jasonjmcghee commented Jan 23, 2024

attempted fix: c12e6a1

@manuel-minniti - lmk if fixed!

@manuel-minniti
Copy link
Author

Thanks for the quick reply, I'll let you know!

@manuel-minniti
Copy link
Author

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?

@jasonjmcghee
Copy link
Owner

jasonjmcghee commented Jan 23, 2024

You can run with RUST_BACKTRACE=1

Are you running Wayland?

If so... tauri-apps/global-hotkey#28

@manuel-minniti
Copy link
Author

RUST_BACKTRACE=1 did not really tell me much.

Yes, I am using Wayland and I have since upgraded NixOS to 24.05 (Uakari).

Screenshot from 2024-01-23 14-05-59

@jasonjmcghee
Copy link
Owner

jasonjmcghee commented Jan 23, 2024

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.

@jasonjmcghee
Copy link
Owner

jasonjmcghee commented Jan 23, 2024

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

@jasonjmcghee jasonjmcghee changed the title Support for NixOS Wayland doesn't support Global Shortcuts and panics Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants