Kiosk process owns its display lifecycle: waits for X11, keeps the fullscreen black canvas below video, stops deterministically on signal. Supervisor starts it before video, restarts only on process death, and shuts the whole process group down; X11 downtime never restarts the supervisor. Per-target opener/template abstractions for future MIPI.
73 lines
1.6 KiB
Go
73 lines
1.6 KiB
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
|
|
"gopkg.in/yaml.v3"
|
|
)
|
|
|
|
// DisplayConfig configures the independent kiosk canvas process.
|
|
type DisplayConfig struct {
|
|
Enabled bool `yaml:"enabled"`
|
|
Command string `yaml:"command"`
|
|
User string `yaml:"user"`
|
|
Display string `yaml:"display"`
|
|
Xauthority string `yaml:"xauthority"`
|
|
}
|
|
|
|
type Config struct {
|
|
Display DisplayConfig `yaml:"display"`
|
|
Serial struct {
|
|
Path string `yaml:"path"`
|
|
} `yaml:"serial"`
|
|
Video struct {
|
|
Enabled bool `yaml:"enabled"`
|
|
AuxIndex int `yaml:"aux_index"`
|
|
Threshold int16 `yaml:"threshold"`
|
|
Command string `yaml:"command"`
|
|
} `yaml:"video"`
|
|
Logging struct {
|
|
Enabled bool `yaml:"enabled"`
|
|
Path string `yaml:"path"`
|
|
} `yaml:"logging"`
|
|
}
|
|
|
|
func Default() Config {
|
|
var c Config
|
|
c.Display = DefaultDisplay()
|
|
c.Serial.Path = "/dev/ttyS0"
|
|
c.Video.Enabled = true
|
|
c.Video.AuxIndex = 5 // AUX2, zero-based
|
|
c.Video.Threshold = -512
|
|
c.Video.Command = "fpv-video"
|
|
c.Logging.Enabled = true
|
|
return c
|
|
}
|
|
|
|
// DefaultDisplay starts the kiosk canvas before video on the desktop X
|
|
// server owned by the unprivileged display user.
|
|
func DefaultDisplay() DisplayConfig {
|
|
return DisplayConfig{
|
|
Enabled: true,
|
|
Command: "/usr/local/bin/groundstation-display",
|
|
User: "orangepi",
|
|
Display: ":0",
|
|
Xauthority: "/home/orangepi/.Xauthority",
|
|
}
|
|
}
|
|
|
|
func Load(path string) (Config, error) {
|
|
config := Default()
|
|
data, err := os.ReadFile(path)
|
|
if err != nil {
|
|
if os.IsNotExist(err) {
|
|
return config, nil
|
|
}
|
|
return config, err
|
|
}
|
|
if err := yaml.Unmarshal(data, &config); err != nil {
|
|
return config, err
|
|
}
|
|
return config, nil
|
|
}
|