From dedfbfce6418c1f574170b62c7e78a374c87a5e5 Mon Sep 17 00:00:00 2001 From: Brandon Lucas Date: Mon, 16 Feb 2026 22:28:10 -0500 Subject: [PATCH] Add QR code support for Device IDs - Add printQR() helper function using qrencode - Display QR code in sync setup for easy mobile pairing - Add qrencode to doctor dependency check Co-Authored-By: Claude Opus 4.5 --- cli/grapho.lux | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/cli/grapho.lux b/cli/grapho.lux index 47d5f4e..119d0ff 100644 --- a/cli/grapho.lux +++ b/cli/grapho.lux @@ -162,6 +162,18 @@ fn printCmd(cmd: String): Unit with {Process} = { () } +// Print a QR code for easy scanning (e.g., device IDs) +fn printQR(data: String): Unit with {Process} = { + if hasCommand("qrencode") then { + // Generate small terminal QR code and redirect to stderr + let ignore = Process.exec("qrencode -t ANSIUTF8 -m 1 '" + data + "' -o - >&2") + () + } else { + // Fallback: just show the data + printHint("(Install qrencode for QR codes)") + } +} + // ============================================================================= // Shell helpers // ============================================================================= @@ -504,7 +516,9 @@ fn doSyncSetup(): Unit with {Process} = { printBold("Your Device ID") let ignore = Process.exec("printf '\\033[33m%s\\033[0m\\n' \"" + deviceId + "\" >&2") print("") - printHint("Share this ID with other devices to pair.") + printQR(deviceId) + print("") + printHint("Scan the QR code or share this ID to pair devices.") logEvent("sync", "Device ID displayed") } else { printStepWarn("Getting device ID", "retry in a moment") @@ -981,6 +995,12 @@ fn showDoctor(): Unit with {Process} = { printStepErr("age", "not found") } + if hasCommand("qrencode") then { + printStep("qrencode", "installed") + } else { + printStepWarn("qrencode", "not found (QR codes disabled)") + } + // Directory check print("") let ignore2 = Process.exec("printf '\\033[2mDirectories:\\033[0m\\n' >&2")