Fix invisible/flashing clock, map Protect's 8-camera preset, warn on gaps
Three separate faults made cameras "not load" and the clock misbehave. Clock rendered as nothing, or flashed ~200ms/second. The time was drawn as an ASS osd-overlay pushed over mpv IPC, but on mpv 0.35 + Mesa/V3D + sway an OSD overlay is rendered only on the frame where its content *changes*. Every layer reports success while this happens (mpv returns error:success, vo-configured is true, and sway reports the window visible at the right rect), so it looks like a stacking or font bug and is neither. Ruled out: pushing at 20Hz (identical content is ignored, so it still only redrew when the second flipped), osd-msg1, show-text, and --pause (mpv stops redrawing entirely). Fonts were never the issue. The time is now baked into every frame by a drawtext filter re-reading a small file the ticker rewrites once a second, with two constraints that cost real time to find and are pinned by tests: - The canvas alpha must be > 0. A fully transparent canvas (black@0.0 with --alpha=yes) makes the glyphs inherit alpha 0 and the compositor draws nothing -- this was the original invisible clock. New clock background_opacity (default 0.45) is clamped in config *and* in args() so no code path can produce an invisible clock. - Readahead must be off. drawtext stamps the time when a frame is *generated*, so buffering ahead makes the visible clock lag by the readahead and swallows text-file updates entirely. Since the text now arrives through a file, the clock needs no IPC socket: dropped --input-ipc-server, the ipcPath field, and the stale-socket removal. assEscape goes with the ASS path. `views import` produced layouts with holes. viewmap derived the grid from the slot count alone and ignored Protect's `layout` field, so Protect's asymmetric 8-camera preset (four 2x2 tiles plus a right column of four 1x1) landed as 8 tiles in a 3x3 grid -- the bottom-right cell was simply empty and rendered as a blank rectangle. That preset is now mapped exactly; other counts keep the uniform GridForSlots fallback rather than guessing at presets I have not observed. Import also warns when a mapping would leave empty cells or references a camera missing from the config, so a silent hole cannot reach the screen again. Also: - clock.corner gains bottom-center and top-center (centered horizontally, Margin still applies vertically). - placeClock no longer re-issues `resize set` every tick. Re-asserting geometry on a correctly-sized window makes sway send a configure event, which makes mpv reallocate buffers and blank for a frame. New compositor.Raise re-asserts z-order only, which is all the 2s tick needs; geometry is re-placed only when it has actually drifted. - README documents why the clock is drawn this way, the preset table and how to add another from `views dump`, and three troubleshooting entries for failure modes that all look like bugs: a blank tile whose mpv is running (a stale camera entry -- re-adopting a camera in Protect assigns a new id and often a slightly different name, and `discover` never prunes), cameras in `cameras:` not being on screen (only the active layout's tiles stream), and black bars inside tiles (non-16:9 grid cells; --panscan=1.0 crops to fill instead). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LYhTnkp7VzJ67THeicgfAQ
This commit is contained in:
@@ -59,7 +59,8 @@ type Clock struct {
|
||||
// Examples: "3:04:05 PM", "Mon Jan 2 15:04".
|
||||
Format string `yaml:"format,omitempty"`
|
||||
// Corner places the overlay: bottom-right (default), bottom-left,
|
||||
// top-right, top-left.
|
||||
// top-right, top-left, bottom-center, top-center. The *-center positions
|
||||
// center the overlay horizontally and ignore Margin on that axis.
|
||||
Corner string `yaml:"corner,omitempty"`
|
||||
// FontSize is the glyph height in pixels (default 44).
|
||||
FontSize int `yaml:"font_size,omitempty"`
|
||||
@@ -68,6 +69,15 @@ type Clock struct {
|
||||
Height int `yaml:"height,omitempty"`
|
||||
// Margin is the gap from the screen edges in pixels (default 24).
|
||||
Margin int `yaml:"margin,omitempty"`
|
||||
// BackgroundOpacity is the alpha of the overlay's backing box, 0.0
|
||||
// (invisible) to 1.0 (solid black). Default 0.45.
|
||||
//
|
||||
// It must not be 0: the time is drawn into the canvas by a drawtext filter,
|
||||
// and on a fully transparent canvas the glyphs inherit the canvas's zero
|
||||
// alpha, so the compositor draws nothing and the clock silently disappears.
|
||||
// A small non-zero value gives the text a dark backing that also keeps it
|
||||
// legible over bright daytime scenes.
|
||||
BackgroundOpacity float64 `yaml:"background_opacity,omitempty"`
|
||||
}
|
||||
|
||||
// Controller holds UniFi Protect connection details.
|
||||
@@ -355,6 +365,14 @@ func (c *Config) Defaults() {
|
||||
if c.Clock.Margin == 0 {
|
||||
c.Clock.Margin = 24
|
||||
}
|
||||
if c.Clock.BackgroundOpacity <= 0 {
|
||||
// 0 renders an invisible clock (see BackgroundOpacity), so treat
|
||||
// unset — and any nonsense value — as the default.
|
||||
c.Clock.BackgroundOpacity = 0.45
|
||||
}
|
||||
if c.Clock.BackgroundOpacity > 1 {
|
||||
c.Clock.BackgroundOpacity = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -407,9 +425,10 @@ func (c *Config) Validate() error {
|
||||
|
||||
if c.Clock.Enabled && c.Clock.Corner != "" {
|
||||
switch c.Clock.Corner {
|
||||
case "bottom-right", "bottom-left", "top-right", "top-left":
|
||||
case "bottom-right", "bottom-left", "top-right", "top-left",
|
||||
"bottom-center", "top-center":
|
||||
default:
|
||||
return fmt.Errorf("clock.corner %q must be one of bottom-right, bottom-left, top-right, top-left", c.Clock.Corner)
|
||||
return fmt.Errorf("clock.corner %q must be one of bottom-right, bottom-left, top-right, top-left, bottom-center, top-center", c.Clock.Corner)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user