Files
mesh-catalog/modules/picom/cmd/picom-tools/main.go
T
jochen 04894e6618 picom: the compositor as a module, claiming node-compositor (hq ADR 0208)
Owns its configuration, moved to picom's window rules; started once from the
session's xinitrc slot; Go tools restart, rules, window-opacity and toggle, which
find the operator's X session from the window manager's environment.
2026-10-04 13:15:39 +02:00

90 lines
3.0 KiB
Go

// picom's Go tools bundle (novox/hq ADR 0188, ADR 0193, ADR 0208): the compositor's own tools, served
// by the node's runtime as the operator account. node-compositor 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() {
if err := stdio.Serve("", tools()); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
func tools() []stdio.Tool {
return []stdio.Tool{
{
Name: "picom_restart",
Description: "Make the compositor re-read its configuration: a running picom is told to reinitialise " +
"(SIGUSR1); with hard, or when none runs, a fresh one is started in the operator's session under " +
"their service manager. Answers what was done and the pids.",
Input: map[string]any{
"hard": map[string]any{"type": "boolean", "description": "end the running picom and start a new one (default false)"},
},
Run: func(args map[string]any) (any, error) {
hard, err := flag(args, "hard", false)
if err != nil {
return nil, err
}
return Restart(hard)
},
},
{
Name: "picom_rules",
Description: "The compositor's configuration in force: its global options and each window rule " +
"(match, opacity, shadow, fade…) in the order picom applies them, from the file the mesh placed, " +
"and whether picom is running.",
Run: func(map[string]any) (any, error) { return Rules(configPath()) },
},
{
Name: "picom_window_opacity",
Description: "Read or set one window's own opacity (_NET_WM_WINDOW_OPACITY), the focused window " +
"unless one is named. A window rule that sets opacity (terminals) outranks it. Lasts as long as " +
"the window; the declared rules are untouched.",
Input: map[string]any{
"window": map[string]any{"type": "string", "description": "X window id, 0x… or decimal (default: the focused window)"},
"opacity": map[string]any{"type": "integer", "description": "0-100 to set; 100 removes the window's own value; omit to read"},
},
Run: func(args map[string]any) (any, error) {
window, err := text(args, "window", false)
if err != nil {
return nil, err
}
if _, set := args["opacity"]; !set {
return WindowOpacity(window, -1)
}
opacity, err := whole(args, "opacity", 100, 0, 100)
if err != nil {
return nil, err
}
return WindowOpacity(window, opacity)
},
},
{
Name: "picom_toggle",
Description: "Turn compositing off or on in the operator's session, for a game or a test: off ends " +
"picom, on starts it. Without `on`, flips it. The session start brings it back at the next login.",
Input: map[string]any{
"on": map[string]any{"type": "boolean", "description": "true to start, false to stop (default: the opposite of now)"},
},
Run: func(args map[string]any) (any, error) {
var want *bool
if _, given := args["on"]; given {
on, err := flag(args, "on", false)
if err != nil {
return nil, err
}
want = &on
}
return Toggle(want)
},
},
}
}