From 8b13928cc0fcc5187234956e08b3c402d2e366d7 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 26 Jun 2026 04:51:17 +0000 Subject: [PATCH] kyber-server: auto-launch AppImage for EA login if no token found If auth.toml has no token, launch the Kyber AppImage as the actual user (with DISPLAY/XAUTHORITY passed through), prompt the user to log in via the EA Account button, then re-read auth.toml once they close Kyber. Falls back to manual token paste if auth.toml still has nothing. Skips the AppImage entirely on rerun when a token is already cached. Co-Authored-By: Claude Sonnet 4.6 Claude-Session: https://claude.ai/code/session_01D8ckUJQtj1pH8jtAddBDZs --- services/kyber-server.sh | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/services/kyber-server.sh b/services/kyber-server.sh index 37ecb3d..dd16a60 100644 --- a/services/kyber-server.sh +++ b/services/kyber-server.sh @@ -242,16 +242,37 @@ for a in data.get('assets', []): if [[ -z "$KYBER_TOKEN" ]]; then echo "" - log_warning "No token found. You need to log in via the Kyber AppImage first." + log_warning "No EA token found — need to log in via Kyber AppImage." + log_info "Launching Kyber as $ACTUAL_USER — click 'EA Account' and log in, then close Kyber." echo "" - echo " ┌─────────────────────────────────────────────────────────────────┐" - echo " │ 1. Open a terminal as yourself (not sudo) │" - echo " │ 2. Run: $APPIMAGE_PATH" - echo " │ 3. Click 'EA Account' and log in via the browser │" - echo " │ 4. Close Kyber, then re-run this installer │" - echo " └─────────────────────────────────────────────────────────────────┘" + read -r -p " Press Enter to launch Kyber now..." _ + + # Launch AppImage as the actual user in the background + sudo -u "$ACTUAL_USER" DISPLAY="${DISPLAY:-:0}" \ + XAUTHORITY="$ACTUAL_HOME/.Xauthority" \ + "$APPIMAGE_PATH" & + local APPIMAGE_PID=$! + echo "" - prompt_text "Or paste your token manually (from auth.toml) and press Enter:" "" KYBER_TOKEN + log_info "Kyber is running (PID $APPIMAGE_PID)." + log_info "Click 'EA Account', log in via the browser, then close Kyber." + echo "" + read -r -p " Press Enter once you have logged in and closed Kyber..." _ + + # Give Maxima a moment to flush auth.toml + sleep 2 + + # Kill AppImage if still running + kill "$APPIMAGE_PID" 2>/dev/null || true + wait "$APPIMAGE_PID" 2>/dev/null || true + + KYBER_TOKEN=$(_kyber_get_token) + fi + + if [[ -z "$KYBER_TOKEN" ]]; then + echo "" + log_warning "Still no token found in auth.toml." + prompt_text "Paste your token manually (or press Enter to abort):" "" KYBER_TOKEN fi if [[ -z "$KYBER_TOKEN" ]]; then