// xterm's tools (novox/hq ADR 0208, research 026/05): node-terminal-emulator's verb `open`, and the // module's own `font` and `colours`. // // A terminal opened by `open` is handed to the account's own service manager (internal/desktop's // Launch), never left a child of the runtime, which the service manager empties at every restart. package main import ( "context" "fmt" "os" "time" stdio "git.novox.be/novox/mesh-sdk/go" "xterm/internal/desktop" ) func main() { if err := stdio.Serve("", tools(xterm{d: desktop.Machine("i3", "sway")})); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } } func call(run func(ctx context.Context, a desktop.Args) (any, error)) func(map[string]any) (any, error) { return func(args map[string]any) (any, error) { ctx, cancel := context.WithTimeout(context.Background(), 25*time.Second) defer cancel() return run(ctx, desktop.Args(args)) } } func tools(x xterm) []stdio.Tool { return []stdio.Tool{ { Name: "node-terminal-emulator.open", Description: "Open a terminal window in the operator's session: the account's login shell, or a command " + "run through it, in a directory (the home when none is named). hold keeps the window open after " + "the command ends. Answers the unit it runs as.", Input: desktop.Schema(map[string]any{ "command": desktop.Str("what to run in it (optional; the login shell when absent)"), "directory": desktop.Str("where it starts (optional; the account's home)"), "title": desktop.Str("the window's title (optional)"), "hold": desktop.Flag("keep the window open after the command ends (default false)"), }), Run: call(x.open), }, { Name: "xterm_font", Description: "The face and size xterm uses, and the installed font that face resolves to. With face " + "and/or size, set them for terminals opened from now on (an installed face only); the module's " + "resources set the default again at the next login.", Input: desktop.Schema(map[string]any{ "face": desktop.Str("a font family, as fc-list names it"), "size": desktop.Num("points, 6 to 48"), }), Run: call(x.font), }, { Name: "xterm_colours", Description: "xterm's colours in force: background, foreground, cursor and the sixteen palette entries, " + "as #rrggbb, each beside the module's default and whether it differs.", Input: desktop.Schema(map[string]any{}), Run: call(x.colours), }, } }