Files
mesh-catalog/modules/xterm/cmd/xterm-tools/main.go
T
jschoubben f178aab641
mesh/delivery-group group fix/1656-xterm-config rejected: a member's own check failed
mesh/merge-gate waits for its group's composed check
mesh/repo-check head f178aab641dc merged into trunk 3259765d46bc beside mesh-controller#420@69a67876 — fail: its merge-check.sh failed: files asking for a …
mesh/delivery superseded: a newer head of the same pull request
Make every xterm resource a config value with today's value as default; tools read the rendered resources (issue 1656)
2026-10-21 12:51:40 +02:00

70 lines
2.5 KiB
Go

// 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"
"path/filepath"
"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"), resources: filepath.Join(desktop.Home(), ResourcesFile)})); 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 72"),
}),
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),
},
}
}