Colour the page nav keys on every page to follow the ALL button.

nav_templates.json holds Companion's own UP / page number / DOWN keys after
'convert to regular button'; make_page.py colours them from the ALL tile and
nav_keys.py copies them onto all 96 other pages (288 keys, recorded in
nav_locations.json; --revert restores the built-in keys). Also rewrites the
README's top half, which an earlier edit had duplicated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 09:40:45 -04:00
co-authored by Claude Opus 5.5
parent 161596cefb
commit 3118cdc281
7 changed files with 1593 additions and 62 deletions
+31 -1
View File
@@ -132,8 +132,38 @@ def button(tid, tile, cfg):
}
NAV_LOCATIONS = {"pageup": ("0", "0"), "pagenum": ("1", "0"), "pagedown": ("2", "0")}
NAV_MARKER = "STATUS nav key"
def nav_key(kind, names):
"""Companion's own UP / page number / DOWN key, coloured like the ALL button."""
templates = json.load(open(os.path.join(HERE, "nav_templates.json")))
key = json.loads(json.dumps(templates[kind]))
stale = "$(internal:time_unix) - $(custom:%s) > %d" % (names["heartbeat"], STALE_SECONDS)
pick = lambda field: "jsonpath($(custom:%s), '$.all.%s')" % (names["state"], field)
bg = "%s ? %d : ($(custom:flash_tick) == 1 ? %s : %s)" % (stale, PURPLE, pick("b"), pick("b2"))
fg = "%s ? %d : ($(custom:flash_tick) == 1 ? %s : %s)" % (stale, 0xFFFFFF, pick("f"), pick("f2"))
def paint(layers):
for layer in layers:
if layer["type"] == "box":
layer["color"] = prop(bg, True)
elif layer["type"] == "text":
layer["color"] = prop(fg, True)
elif layer["type"] == "line":
layer["borderColor"] = prop(fg, True)
paint(layer.get("children", []))
paint(key["style"]["layers"])
key["options"]["notes"] = ("%s (%s): colour follows the ALL button on the status page. "
"Undo on every page with: python3 nav_keys.py --revert" % (NAV_MARKER, kind))
return key
def build(cfg):
controls = {"0": {"0": {"type": "pageup"}}, "1": {"0": {"type": "pagenum"}}, "2": {"0": {"type": "pagedown"}}}
controls = {}
for kind, (r, c) in NAV_LOCATIONS.items():
controls.setdefault(r, {})[c] = nav_key(kind, cfg["variables"])
for tile in cfg["tiles"]:
if "pos" not in tile:
continue