diff --git a/services/wolf.sh b/services/wolf.sh index 6d0d9f4..e587926 100644 --- a/services/wolf.sh +++ b/services/wolf.sh @@ -3423,8 +3423,24 @@ COMPEOF # recognize ("oh, that's my gaming PC"). SESSIONS_JSON=$(sudo curl -fsS --unix-socket "$SOCK" http://localhost/api/v1/sessions 2>/dev/null) + # Wolf doesn't dedupe repeated pairings of the same device (confirmed + # live: re-pairing the same PC 6 times over produced 6 separate list + # entries, all with the identical client_id) — and Wolf's own + # get_client_by_id() (config.hpp) resolves by taking the FIRST match + # for a given id anyway, so every duplicate beyond the first is a + # dead ringer with no functional difference. Rather than force a + # choice between 6 identical-outcome options (confirmed live: this + # was a real, confusing thing to be asked to do), the picker only + # ever shows DISTINCT client_ids, first-occurrence order — matching + # what Wolf itself would actually resolve to regardless of which + # duplicate got picked. CLIENT_IDS=() - while IFS= read -r cid; do CLIENT_IDS+=("$cid"); done < <(echo "$CLIENTS_JSON" | python3 -c " + while IFS= read -r cid; do + for existing in "${CLIENT_IDS[@]}"; do + [ "$existing" = "$cid" ] && continue 2 + done + CLIENT_IDS+=("$cid") + done < <(echo "$CLIENTS_JSON" | python3 -c " import json, sys for c in json.load(sys.stdin)['clients']: print(c['client_id']) @@ -3435,7 +3451,7 @@ for c in json.load(sys.stdin)['clients']: fi echo "" - echo "Paired clients (ACTIVE = streaming from this IP right now — the" + echo "Paired devices (ACTIVE = streaming from this IP right now — the" echo "reliable way to tell which entry is yours. If nothing shows" echo "ACTIVE, start streaming from the device you want to configure," echo "leave it connected, and re-run this in another terminal):" @@ -3446,21 +3462,21 @@ try: active = {s['client_id']: s['client_ip'] for s in json.loads(sys.argv[1]).get('sessions', []) if s.get('client_id')} except Exception: active = {} -for i, c in enumerate(d['clients']): - ov = c['settings'].get('controllers_override') or [] +seen = [] +counts = {} +for c in d['clients']: cid = c['client_id'] + counts[cid] = counts.get(cid, 0) + 1 + if cid not in seen: + seen.append(cid) +for i, cid in enumerate(seen): + first = next(c for c in d['clients'] if c['client_id'] == cid) + ov = first['settings'].get('controllers_override') or [] tag = 'ACTIVE - streaming from ' + active[cid] if cid in active else 'not currently connected' - print(f\" {i+1}) {cid} [{tag}]\") + dup = f\" (paired {counts[cid]}x)\" if counts[cid] > 1 else '' + print(f\" {i+1}) {cid}{dup} [{tag}]\") print(f\" current override: {ov if ov else 'none - auto-detect'}\") " "$SESSIONS_JSON" - DUP_COUNT=$(printf '%s\n' "${CLIENT_IDS[@]}" | sort | uniq -d | wc -l) - if [ "$DUP_COUNT" -gt 0 ]; then - echo "" - echo "Note: some client_ids above are repeated — the same device was" - echo "paired more than once (each pairing gets its own entry, Wolf" - echo "doesn't dedupe). Harmless, but if you want a clean list, forget" - echo "/ re-pair this PC from Moonlight's own settings on the client." - fi ACTIVE_CLIENT_ID=$(python3 -c " import json, sys @@ -4246,10 +4262,12 @@ is actively streaming right now with its real IP address, e.g. it's used automatically with no prompt. **For the clearest result: start streaming from the device you want to configure, leave it connected, and run this command while it's still connected** — then there's no -guessing. It's also normal to see the same client_id listed more than -once (Wolf doesn't dedupe repeated pairings of the same device) — every -duplicate of an active ID is tagged ACTIVE together, so it doesn't matter -which one you'd have picked by hand. +guessing. Wolf doesn't dedupe repeated pairings of the same device — if +you've paired the same PC more than once, this tool collapses those +into a single listed entry tagged e.g. \`(paired 6x)\` instead of forcing +a choice between several options that all resolve identically (confirmed +live: being asked to pick between 6 identical-outcome entries was +genuinely confusing before this). **It labels controllers "1st"/"2nd"/"3rd"/"4th" — always meaning Wolf's own "controller 0"/"controller 1"/"controller 2"/"controller 3".** Wolf's own