aboutsummaryrefslogtreecommitdiffstats
path: root/gbctl
diff options
context:
space:
mode:
authorgbc dev <gbc@localhost>2026-07-15 10:10:16 +0200
committergbc dev <gbc@localhost>2026-07-15 10:10:16 +0200
commitd52d92092d98ed2d6c48e6433cacb899582f617e (patch)
tree7e835fb815d6ec868b2362b37bab63f8365857dc /gbctl
parentfix(control): ignore SIGPIPE so a vanishing client can't kill the emulator (diff)
downloadsl0pboy-d52d92092d98ed2d6c48e6433cacb899582f617e.tar.gz
sl0pboy-d52d92092d98ed2d6c48e6433cacb899582f617e.tar.xz
sl0pboy-d52d92092d98ed2d6c48e6433cacb899582f617e.zip
gbctl: 'hud' kills any existing HUD pane before spawning (no double-HUD)
gbctl hud now scans tmux for panes started with gbhud.py and kills them before spawning, so there's never more than one HUD (fixes the double-spawn flicker). Added 'gbctl hud --kill' to just tear the HUD down.
Diffstat (limited to 'gbctl')
-rwxr-xr-xgbctl27
1 files changed, 26 insertions, 1 deletions
diff --git a/gbctl b/gbctl
index 4c3d4f9..287b16a 100755
--- a/gbctl
+++ b/gbctl
@@ -284,11 +284,35 @@ def cmd_screen(argv):
r = subprocess.run(args, capture_output=True, text=True)
sys.stdout.write(r.stdout)
+def _kill_hud_panes():
+ # kill any pane whose start command references the HUD, so there's never
+ # more than one HUD running (avoids the double-spawn tmux flicker).
+ n = 0
+ try:
+ r = subprocess.run(
+ ["tmux", "list-panes", "-a", "-F", "#{pane_id}\t#{pane_start_command}"],
+ capture_output=True, text=True)
+ for line in r.stdout.splitlines():
+ pid, _, startcmd = line.partition("\t")
+ if "gbhud.py" in startcmd:
+ subprocess.run(["tmux", "kill-pane", "-t", pid], capture_output=True)
+ n += 1
+ except Exception:
+ pass
+ return n
+
def cmd_hud(argv):
# spawn a tmux pane running the live debug HUD, bound to the resolved socket
+ killonly = "--kill" in argv
+ if killonly:
+ argv = [a for a in argv if a != "--kill"]
+ k = _kill_hud_panes()
+ print("killed %d hud pane(s)" % k)
+ return
sock_path = _resolve_sock(argv)
if "TMUX" not in os.environ:
die("not inside tmux; gbctl hud needs a tmux session")
+ killed = _kill_hud_panes() # never leave a second HUD around
hud = os.path.join(HERE, "tools", "gbhud.py")
split = "-h"
if "--split" in argv:
@@ -298,7 +322,8 @@ def cmd_hud(argv):
capture_output=True, text=True)
if r.returncode != 0:
die("tmux spawn failed: %s" % r.stderr.strip())
- print("hud pane=%s sock=%s" % (r.stdout.strip(), sock_path))
+ note = (" (replaced %d)" % killed) if killed else ""
+ print("hud pane=%s sock=%s%s" % (r.stdout.strip(), sock_path, note))
def cmd_monitor(argv):
secs = float(argv[0]) if argv and _isnum(argv[0]) else None