Hold the page number key for one second to jump to the status page.

A tap still goes to the start page, now on release so a hold does not flash
through page 1 first. Hold time is nav_hold_ms in config.json.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 09:52:21 -04:00
co-authored by Claude Opus 5.5
parent 815a4ae0e4
commit a5972d646f
5 changed files with 28 additions and 5 deletions
+17 -3
View File
@@ -136,8 +136,13 @@ NAV_LOCATIONS = {"pageup": ("0", "0"), "pagenum": ("1", "0"), "pagedown": ("2",
NAV_MARKER = "STATUS nav key"
def nav_key(kind, names):
"""Companion's own UP / page number / DOWN key, coloured like the ALL button."""
def nav_key(kind, names, status_page=None, hold_ms=1000):
"""Companion's own UP / page number / DOWN key, coloured like the ALL button.
For the page number key, status_page adds: tap = Companion's usual "go to the
start page" (moved to release, so a hold does not flash through it first),
hold for hold_ms = go to the status page.
"""
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)
@@ -155,6 +160,14 @@ def nav_key(kind, names):
layer["borderColor"] = prop(fg, True)
paint(layer.get("children", []))
paint(key["style"]["layers"])
if kind == "pagenum" and status_page:
step = key["steps"]["0"]
tap = step["action_sets"]["down"]
hold = [{"type": "action", "id": stable_id("nav", "hold"), "definitionId": "set_page",
"connectionId": "internal",
"options": {"surfaceId": prop("self"), "page": prop(status_page)}, "children": {}}]
step["action_sets"] = {"down": [], "up": tap, str(hold_ms): hold}
step["options"]["runWhileHeld"] = [hold_ms]
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
@@ -164,7 +177,8 @@ def build(cfg):
controls = {}
coloured = cfg.get("nav_keys", list(NAV_LOCATIONS)) # which nav keys follow the ALL button
for kind, (r, c) in NAV_LOCATIONS.items():
controls.setdefault(r, {})[c] = nav_key(kind, cfg["variables"]) if kind in coloured else {"type": kind}
controls.setdefault(r, {})[c] = (nav_key(kind, cfg["variables"], cfg["page"], cfg.get("nav_hold_ms", 1000))
if kind in coloured else {"type": kind})
for tile in cfg["tiles"]:
if "pos" not in tile:
continue