Files
discord-lobby-mute/hotkey_notwindows.go
richard 72f3ddde5f Add evdev hotkey backend for Wayland compatibility on Linux
On Wayland, XGrabKey via XWayland is not forwarded by most compositors.
The new Linux implementation tries evdev first (works on Wayland and X11
without compositor-specific support — requires 'input' group or systemd-logind
seat ACLs, which GNOME/KDE grant automatically). Falls back to X11 XGrabKey
for plain X11 sessions or when evdev devices aren't accessible. The log now
records which backend was selected.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-01 19:55:49 +03:00

25 lines
436 B
Go

//go:build !windows && !linux
package main
import "golang.design/x/hotkey"
func startHotkey(keybind string) (<-chan struct{}, error) {
mods, key, err := parseKeybind(keybind)
if err != nil {
return nil, err
}
hk := hotkey.New(mods, key)
if err := hk.Register(); err != nil {
return nil, err
}
out := make(chan struct{})
go func() {
for range hk.Keydown() {
out <- struct{}{}
}
close(out)
}()
return out, nil
}