Files
mesh-catalog/modules/i3status-rust/cmd/i3status-rust-tools/main.go
T
jochen 76b63744e6 Carry the power draw to the bar over the bus, not through a file (hq ADR 0260)
Modules talk over the bus. The power module's bundle puts each fresh reading of its own
sampler in its state draw, keyed by the machine; the bar's block shows that state, which
the bar's bundle watches under the read the mesh grants it. A new catalogue check refuses
a module naming another module's path under /run or /var/lib.
2026-10-08 16:12:37 +02:00

84 lines
2.6 KiB
Go

// i3status-rust's Go tools bundle (novox/hq ADR 0188, ADR 0193, ADR 0208): the bars' tools, served by
// the node's runtime as the operator account. node-bar has no verbs yet (ADR 0208 §2), so every tool
// here is the module's own.
package main
import (
"fmt"
"os"
stdio "git.novox.be/novox/mesh-sdk/go"
)
func main() {
// The values other modules keep on the bus for their blocks (novox/hq ADR 0260).
go FollowValues()
if err := stdio.Serve("", tools()); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
var barInput = map[string]any{"type": "string", "enum": bars, "description": "which bar (default: both)"}
func tools() []stdio.Tool {
return []stdio.Tool{
{
Name: "i3status_rust_reload",
Description: "Make the running bars re-read their configuration (i3status-rs restarts in place). " +
"Answers the processes reached.",
Run: func(map[string]any) (any, error) { return Reload(), nil },
},
{
Name: "i3status_rust_blocks",
Description: "What each bar shows: every block in order, its kind and settings, and with values " +
"(the default) what it shows right now, from one run of the bar's configuration.",
Input: map[string]any{
"bar": barInput,
"values": map[string]any{"type": "boolean", "description": "run the bar once to read each block's current text (default true; a few seconds)"},
},
Run: func(args map[string]any) (any, error) {
bar, err := text(args, "bar", false)
if err != nil {
return nil, err
}
values, err := flag(args, "values", true)
if err != nil {
return nil, err
}
return Blocks(bar, values)
},
},
{
Name: "i3status_rust_block_run",
Description: "Run one block of a bar once, alone, and answer what it shows — to see a block that " +
"errors, or what a click would act on.",
Input: map[string]any{
"type": "object",
"properties": map[string]any{
"bar": map[string]any{"type": "string", "enum": bars},
"index": map[string]any{"type": "integer", "description": "the block's position in the bar, from 0, as i3status_rust_blocks answers it"},
},
"required": []string{"bar", "index"},
},
Run: func(args map[string]any) (any, error) {
bar, err := text(args, "bar", true)
if err != nil {
return nil, err
}
index, err := whole(args, "index", 0, 0, 200)
if err != nil {
return nil, err
}
return BlockRun(bar, index)
},
},
{
Name: "i3status_rust_themes",
Description: "The bar themes on this machine (the distribution's and the account's own) and the " +
"one each bar uses.",
Run: func(map[string]any) (any, error) { return Themes(themeDirs()), nil },
},
}
}