Skip to content

Instantly share code, notes, and snippets.

@Interpause
Created December 19, 2025 05:44
Show Gist options
  • Select an option

  • Save Interpause/90731e26961b8e528f04a331dedbc1d1 to your computer and use it in GitHub Desktop.

Select an option

Save Interpause/90731e26961b8e528f04a331dedbc1d1 to your computer and use it in GitHub Desktop.
Autostart ADB tunnel for Oculus headset using systemd and udev
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="2833", TAG+="systemd", ENV{SYSTEMD_WANTS}="wivrn-adb-tunnel.service"
[Unit]
Description=WiVRn ADB reverse tunnel (used by udev)
[Service]
Type=oneshot
ExecStartPre=/usr/bin/sleep 3
ExecStart=/usr/bin/local/wivrn-adb-tunnel.sh
#!/usr/bin/env bash
set -euo pipefail
OCULUS_VENDOR_ID=2833
ADB_BIN=/usr/bin/adb
PORT=tcp:9757
if ! "$ADB_BIN" version >/dev/null 2>&1; then
echo ADB not available
exit 1
fi
serial=$(lsusb -vd 2833: | grep iSerial | awk '{print $3}' | head -n1 || true)
if [ -n "$serial" ]; then
echo serial found: $serial
if "${ADB_BIN}" -s $serial reverse $PORT $PORT; then
echo connection success
exit 0
else
echo adb tunnel failed
fi
else
echo device not found in lsusb
fi
echo connection failed
exit 1
@Interpause
Copy link
Author

So wivrn-adb-tunnel.sh should go into your /usr/local/bin, wivrn-adb-tunnel.service goes into your /etc/systemd/systemand99-oculus-adb.rulesgoes into/etc/udev/rules.d. Make sure to reload systemd service daemon systemctl daemon-reloadand udev rulesudevadm control --reload-rules`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment