// triggerhappy's Go tools bundle (novox/hq ADR 0212): the holder of node-hotkeys. The daemon sees // the keys the window manager never does — a laptop's vendor keys — and runs the trigger lines every // module on the machine contributed. Served by the node's runtime as the operator account. package main import ( "fmt" "os" stdio "git.novox.be/novox/mesh-sdk/go" ) func main() { if err := stdio.Serve("", tools(NewMachine())); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } } func tools(m *Machine) []stdio.Tool { return []stdio.Tool{ { Name: "triggerhappy_keys", Description: "Every hotkey trigger in force on this machine: the key, when it fires (pressed, held, " + "released), the command it runs, the file it is in and the module that contributed it. " + "Warns about a key bound twice for the same state, which fires both commands.", Run: func(map[string]any) (any, error) { return m.Keys() }, }, { Name: "triggerhappy_devices", Description: "The input devices the hotkey daemon reads: each event device's name and what it reports.", Run: func(map[string]any) (any, error) { return m.Devices() }, }, { Name: "triggerhappy_dump", Description: "Listen for key events for a few seconds and say which key names arrive, so a key's name " + "can be found for a new trigger: press the key while this runs. Needs sudo -n for the devices.", Input: map[string]any{ "seconds": map[string]any{"type": "integer", "description": "how long to listen (default 5, at most 20)"}, }, Run: func(args map[string]any) (any, error) { s := 5 if v, ok := args["seconds"].(float64); ok { s = int(v) } if s < 1 || s > 20 { return nil, fmt.Errorf("seconds is 1 to 20") } return m.Dump(s) }, }, { Name: "triggerhappy_check", Description: "Whether the hotkey daemon is as the mesh declares it: running, as the operator's account, " + "reading only the mesh's trigger file, with no key bound twice.", Run: func(map[string]any) (any, error) { return m.Check() }, }, } }