// screen-lock's Go tools bundle (novox/hq ADR 0188, ADR 0193, ADR 0208): its implementation of // node-lock-screen's verb `lock`, and its own tools for the idle timeouts, 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()); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } } func tools() []stdio.Tool { return []stdio.Tool{ { Name: "node-lock-screen.lock", Description: "Lock the operator's session now. It goes through logind, so the one locker the " + "session runs answers it, as the lock key and a closed lid do. Answers whether the screen is " + "locked and since when.", Run: func(map[string]any) (any, error) { return Lock() }, }, { Name: "screen_lock_idle", Description: "The screen's idle timeouts: after how long idle the session locks (the X screensaver) " + "and when the displays go to standby, suspend and off (DPMS). Give any of them to change it for " + "this session; the declared ones return at the next login.", Input: map[string]any{ "lock_after_seconds": map[string]any{"type": "integer", "description": "idle time before the lock; 0 never"}, "standby_seconds": map[string]any{"type": "integer", "description": "DPMS standby; 0 never"}, "suspend_seconds": map[string]any{"type": "integer", "description": "DPMS suspend; 0 never"}, "off_seconds": map[string]any{"type": "integer", "description": "DPMS off; 0 never"}, }, Run: func(args map[string]any) (any, error) { change, err := idleChangeOf(args) if err != nil { return nil, err } return Idle(change) }, }, { Name: "screen_lock_inhibit", Description: "Keep the screen on and unlocked for a while — a presentation, a film, a long read: " + "no idle lock and no display power-off for `minutes`, then the timeouts as they were. 0 ends an " + "inhibition early. A lock asked for by hand, by the lid or before suspend still locks.", Input: map[string]any{ "type": "object", "properties": map[string]any{ "minutes": map[string]any{"type": "integer", "description": fmt.Sprintf("how long, 1-%d; 0 ends it now", mostInhibit)}, }, "required": []string{"minutes"}, }, Run: func(args map[string]any) (any, error) { if _, given := args["minutes"]; !given { return nil, fmt.Errorf("minutes is required") } minutes, err := whole(args, "minutes", 0, 0, mostInhibit) if err != nil { return nil, err } return Inhibit(minutes) }, }, { Name: "screen_lock_locked", Description: "Is the operator's session locked now, and since when; whether the lock watcher " + "(xss-lock) runs, and whether an inhibition is keeping the screen on.", Run: func(map[string]any) (any, error) { return Locked() }, }, } }