Add tests and multi-platform keybind support (Linux, macOS, Windows)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-01 18:11:12 +03:00
parent cecd50361c
commit 4f94c4f20b
6 changed files with 340 additions and 20 deletions
+6 -11
View File
@@ -21,9 +21,12 @@ type Config struct {
ExemptUsers []string `json:"exempt_users"`
}
func loadConfig() (*Config, error) {
exe, _ := os.Executable()
for _, dir := range []string{filepath.Dir(exe), "."} {
func loadConfig(dirs ...string) (*Config, error) {
if len(dirs) == 0 {
exe, _ := os.Executable()
dirs = []string{filepath.Dir(exe), "."}
}
for _, dir := range dirs {
data, err := os.ReadFile(filepath.Join(dir, "config.json"))
if err != nil {
continue
@@ -37,14 +40,6 @@ func loadConfig() (*Config, error) {
return nil, fmt.Errorf("config.json not found next to executable or in working directory")
}
var modMap = map[string]hotkey.Modifier{
"ctrl": hotkey.ModCtrl,
"shift": hotkey.ModShift,
"alt": hotkey.ModAlt,
"win": hotkey.ModWin,
"super": hotkey.ModWin,
}
var keyMap = map[string]hotkey.Key{
"a": hotkey.KeyA, "b": hotkey.KeyB, "c": hotkey.KeyC, "d": hotkey.KeyD,
"e": hotkey.KeyE, "f": hotkey.KeyF, "g": hotkey.KeyG, "h": hotkey.KeyH,