// adwaita's tools (novox/hq ADR 0208, research 026/05): appearance (dark or light for GTK, Qt and the // portal at once), cursor, icons and portal-check. The predecessor's appearance script is folded into // the first, and into the module's session line. // // None needs the display except setting the cursor's X resources: GSettings, the portal and the user // manager are reached on the account's own bus, which exists whenever the operator's user manager // runs. package main import ( "context" "fmt" "os" "path/filepath" "time" stdio "git.novox.be/novox/mesh-sdk/go" "adwaita/internal/desktop" ) func main() { home := desktop.Home() a := adwaita{ d: desktop.Machine("i3", "sway"), home: home, iconDirs: []string{filepath.Join(home, ".local", "share", "icons"), filepath.Join(home, ".icons"), "/usr/local/share/icons", "/usr/share/icons"}, portalDirs: []string{"/usr/share/xdg-desktop-portal/portals"}, uid: os.Getuid(), } if err := stdio.Serve("", tools(a)); 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(a adwaita) []stdio.Tool { return []stdio.Tool{ { Name: "adwaita_appearance", Description: "Dark or light, as each audience sees it now: GSettings (which the portal serves to " + "Electron, Firefox and flatpaks), the portal's own answer, the GTK settings files, Qt's palette " + "and the theme words in the user manager's environment. With mode, switch GSettings for the " + "running session and answer which audiences follow live and which keep the module's dark " + "default until it is a setting.", Input: desktop.Schema(map[string]any{"mode": desktop.Enum("switch to (optional)", "dark", "light")}), Run: call(a.appearance), }, { Name: "adwaita_cursor", Description: "The cursor theme and size in force (GSettings, the X resources, XCURSOR_* in the user " + "manager) and the cursor themes installed. With theme and/or size, set them for windows opened " + "from now on; the module's defaults return at the next login.", Input: desktop.Schema(map[string]any{ "theme": desktop.Str("an installed cursor theme"), "size": desktop.Int("pixels, 8 to 256"), }), Run: call(a.cursor), }, { Name: "adwaita_icons", Description: "The icon themes installed (name, where, what each inherits, whether it carries cursors) " + "and the one GTK and Qt are set to use.", Input: desktop.Schema(map[string]any{}), Run: call(a.icons), }, { Name: "adwaita_portal_check", Description: "Which xdg-desktop-portal backend answers which interface for this desktop: the backends " + "installed and what they implement, the portals.conf that decides (and which one won), the " + "resulting backend per interface, whether the portal and each backend are running on the " + "account's bus, and the colour scheme the portal answers.", Input: desktop.Schema(map[string]any{}), Run: call(a.portalCheck), }, } }