Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > alt.os.linux > #82810
| From | Maria Sophia <mariasophia@comprehension.com> |
|---|---|
| Newsgroups | alt.os.linux, comp.mobile.android, alt.comp.os.windows-10 |
| Subject | Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing |
| Date | 2026-06-15 14:43 -0500 |
| Organization | BWH Usenet Archive (https://usenet.blueworldhosting.com) |
| Message-ID | <110pkl6$lip$1@nnrp.usenet.blueworldhosting.com> (permalink) |
| References | <110b60u$25n1$1@nnrp.usenet.blueworldhosting.com> <a_-dnRjhJc7QXLL3nZ2dnZfqnPGdnZ2d@giganews.com> <110p881$fqua$1@dont-email.me> <GEadnXuS5InOqK33nZ2dnZfqnPadnZ2d@giganews.com> <110pim7$3104$1@nnrp.usenet.blueworldhosting.com> |
Cross-posted to 3 groups.
Maria Sophia wrote:
> The question is how to run adb/scrcpy over Wi-Fi in a single step.
> And, how to launch scrcpy mirroring without the console window.
Since everything we automate should also work on Linux, here's an
(untested) shell script that Linux users can test out for the team.
The goal is to eliminate *all* the haslses when using adb over Wi-Fi (or
USB) and when using scrcpy to mirror the Android phone onto the monitor.
#!/bin/bash
# ###########################################################################
# adbconnect.sh (Automate Android-to-desktop Wi-Fi adb/scrcpy connections)
# Solves two problems when connecting a desktop to adb/scrcpy for Android.
# 1. Eliminate all useless random-security steps in a Wi-Fi adb connection
# 2. Eliminate the useless scrcpy console window which just takes up space
#
# v1p7_lnx 20260615
# Ported to Linux bash syntax. Removed all Windows VBS console-hiding
# workarounds. Used native Linux backgrounding (&) and disown.
# ###########################################################################
# ---------------------------------------------------------------------------
# USER VARIABLES & CONFIGURATION
# ---------------------------------------------------------------------------
# For phones with static IP addresses, change the next line
PHONE_IP="192.168.1.2"
SCRCPY_OPTS="--keyboard=sdk --always-on-top"
echo ""
echo "=== ADB Wireless Auto-Connect ==="
echo "=== [Developer options > Wireless debugging > on] ==="
echo ""
# ---------------------------------------------------------------------------
# STEP 1: LOCATE ADB BINARY
# ---------------------------------------------------------------------------
# 'which' locates a command binary path in Linux.
# If not found, output errors to /dev/null (silence)
ADB=$(which adb 2>/dev/null)
if [ -z "$ADB" ]; then
echo "[ERROR] adb binary not found in your PATH."
echo "Please install adb via your package manager (e.g., sudo apt install adb)."
exit 1
fi
echo "Using ADB: $ADB"
echo ""
# ---------------------------------------------------------------------------
# STEP 2: CHECK EXISTING CONNECTIONS
# ---------------------------------------------------------------------------
echo "Checking existing ADB devices..."
# 'adb devices' returns a header followed by active devices.
# We skip the first line (header) using tail, look for a line matching our IP,
# and extract the first block (the exact target identifier).
DEVICE_ID=$("$ADB" devices | tail -n +2 | grep "$PHONE_IP" | awk '{print $1}')
if [ -not -z "$DEVICE_ID" ]; then
echo "Already connected on $DEVICE_ID"
# Re-verify and jump to standard TCP/IP fallback sequence
echo "Switching device $DEVICE_ID to TCP/IP 5555..."
"$ADB" -s "$DEVICE_ID" tcpip 5555
"$ADB" connect "$PHONE_IP:5555"
# Jump to final scrcpy phase
DEVICE_ID="$PHONE_IP:5555"
echo "Launching scrcpy completely silent..."
scrcpy --tcpip="$PHONE_IP" $SCRCPY_OPTS >/dev/null 2>&1 &
disown
echo "Done."
exit 0
fi
echo "Not connected. Need to pair."
echo ""
# ---------------------------------------------------------------------------
# STEP 3: CONSOLE PROMPTS FOR PAIRING DATA
# ---------------------------------------------------------------------------
echo "Necessary pairing information will be shown on the phone:"
# Prompt syntax: read -p "Prompt message: " VARIABLE
# The code syntax '${VARIABLE:-default}' preserves default values if input is blank
read -p "Phone IP [$PHONE_IP] : " INPUT_IP
PHONE_IP=${INPUT_IP:-$PHONE_IP}
read -p "Wireless debugging pairing port (e.g., 333123 on phone): " PAIR_PORT
read -p "Wireless debugging pairing code (e.g., 555123 on phone): " PAIR_CODE
read -p "Wireless debugging debug port (e.g., 444123 on phone): " DEBUG_PORT
echo ""
echo "Pairing with: $PHONE_IP:$PAIR_PORT"
# ---------------------------------------------------------------------------
# STEP 4: RETRY LOGIC FOR ADB PAIRING
# ---------------------------------------------------------------------------
ATTEMPTS_PAIR=0
while [ $ATTEMPTS_PAIR -lt 3 ]; do
ATTEMPTS_PAIR=$((ATTEMPTS_PAIR + 1))
"$ADB" pair "$PHONE_IP:$PAIR_PORT" "$PAIR_CODE"
if [ $? -eq 0 ]; then
# Pair succeeded break the retry loop
break
else
if [ $ATTEMPTS_PAIR -lt 3 ]; then
echo "Pair failed, retrying in 2 seconds..."
sleep 2
else
echo "[ERROR] adb pair failed after $ATTEMPTS_PAIR attempts."
echo "Hint: Open Wireless debugging -> 'Pair device with pairing code' on the phone, then re-run this script."
exit 1
fi
fi
done
echo ""
echo "Connecting to debug port: $PHONE_IP:$DEBUG_PORT"
# ---------------------------------------------------------------------------
# STEP 5: RETRY LOGIC FOR ADB CONNECTION
# ---------------------------------------------------------------------------
ATTEMPTS_CONN=0
while [ $ATTEMPTS_CONN -lt 3 ]; do
ATTEMPTS_CONN=$((ATTEMPTS_CONN + 1))
"$ADB" connect "$PHONE_IP:$DEBUG_PORT"
if [ $? -eq 0 ]; then
# Connection succeeded break the loop
break
else
if [ $ATTEMPTS_CONN -lt 3 ]; then
echo "Connect failed, retrying in 2 seconds..."
sleep 2
else
echo "[ERROR] adb connect $PHONE_IP:$DEBUG_PORT failed after $ATTEMPTS_CONN attempts."
echo "Hint: Ensure phone is on the same Wi-Fi and Wireless debugging pairing UI is active."
exit 2
fi
fi
done
echo ""
# ---------------------------------------------------------------------------
# STEP 6: CAPTURE EMISSIVE IP/PORT SCHEMES
# ---------------------------------------------------------------------------
# Re-scan adb devices to parse dynamic port assignments
DEVICE_ID=$("$ADB" devices | grep "$PHONE_IP" | awk '{print $1}' | head -n 1)
if [ -z "$DEVICE_ID" ]; then
# Fallback structure: isolate any active digital network string address
DEVICE_ID=$("$ADB" devices | tail -n +2 | grep -E '[0-9]' | awk '{print $1}' | head -n 1)
fi
if [ ! -z "$DEVICE_ID" ]; then
echo "Found device id: \"$DEVICE_ID\""
else
echo "[WARN] No device id found after connect. Continuing using $PHONE_IP:$DEBUG_PORT for tcpip attempt."
DEVICE_ID="$PHONE_IP:$DEBUG_PORT"
fi
# ---------------------------------------------------------------------------
# STEP 7: TRANSITION TO PERSISTENT PORT 5555
# ---------------------------------------------------------------------------
echo "Switching to TCP/IP 5555..."
"$ADB" -s "$DEVICE_ID" tcpip 5555
echo ""
echo "Connecting final port: $PHONE_IP:5555"
"$ADB" connect "$PHONE_IP:5555"
echo ""
# ---------------------------------------------------------------------------
# STEP 8: SILENTLY DEPLOY SCRCPY
# ---------------------------------------------------------------------------
echo "Launching scrcpy completely silent..."
# How it works in Linux:
# '>/dev/null 2>&1' strips all console logs/outputs out completely.
# '&' forks the program safely to a background daemon worker thread.
# 'disown' severs ties to the controlling terminal, ensuring it stays open when this terminal closes.
scrcpy --tcpip="$PHONE_IP" $SCRCPY_OPTS >/dev/null 2>&1 &
disown
echo "Done."
exit 0
--
On Usenet, volunteers can find a solution which everyone can then use.
Back to alt.os.linux | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-10 02:07 -0600
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-11 21:49 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-12 16:17 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Hank Rogers <Hank@nospam.invalid> - 2026-06-12 16:32 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Give It A Try <try.it@invalid.invalid> - 2026-06-12 23:20 +0100
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-13 11:31 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing 🇵🇱Jacek Marcin Jaworski🇵🇱 <jmj@energokod.gda.pl> - 2026-06-15 11:08 +0200
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Paul <nospam@needed.invalid> - 2026-06-15 12:11 -0400
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing 🇵🇱Jacek Marcin Jaworski🇵🇱 <jmj@energokod.gda.pl> - 2026-06-15 19:24 +0200
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-15 14:10 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-15 14:43 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing vallor <vallor@vallor.earth> - 2026-06-17 00:16 +0000
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-16 23:23 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-15 13:56 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Warpinator <invalid@invalid.invalid> - 2026-06-16 00:23 +0100
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-15 19:18 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing "Carlos E. R." <robin_listas@es.invalid> - 2026-06-16 12:15 +0200
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Chris <ithinkiam@gmail.com> - 2026-06-16 07:07 +0000
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-16 02:21 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing "Carlos E. R." <robin_listas@es.invalid> - 2026-06-16 12:30 +0200
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-16 12:07 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing "Carlos E. R." <robin_listas@es.invalid> - 2026-06-16 20:11 +0200
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-16 14:40 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing "Carlos E. R." <robin_listas@es.invalid> - 2026-06-16 22:47 +0200
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-16 15:51 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing "Carlos E. R." <robin_listas@es.invalid> - 2026-06-18 00:45 +0200
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Hank Rogers <Hank@nospam.invalid> - 2026-06-17 17:56 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing "....winston" <winstonmvp@gmail.com> - 2026-06-16 19:47 -0400
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-16 23:26 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Chris <ithinkiam@gmail.com> - 2026-06-16 12:10 +0000
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-16 12:09 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-26 06:38 -0400
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-20 02:22 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-20 02:31 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-21 00:53 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-27 08:58 -0400
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Nadia Jarvis <invalid@invalid.invalid> - 2026-06-27 19:38 +0100
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Hank Rogers <Hank@nospam.invalid> - 2026-06-27 19:53 -0500
Re: PSA: Streamlined persistent ADB port over Wi‑Fi without repeated pairing Maria Sophia <mariasophia@comprehension.com> - 2026-06-27 23:01 -0600
csiph-web