Add system tray icon, file logging, and fix Windows hotkey conflict
- Adds fyne.io/systray with a programmatic monkey face icon and Quit menu item - Logs to discord-lobby-mute.log next to the exe so startup errors are visible without a console window - Windows now uses raw Win32 RegisterHotKey in a locked goroutine instead of golang.design/x/hotkey, avoiding a deadlock where systray and the hotkey library both try to own the main thread message loop - Build with: GOOS=windows GOARCH=amd64 go build -ldflags "-H windowsgui" -o discord-lobby-mute.exe . Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
//go:build !windows
|
||||
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user