Created
December 19, 2025 05:44
-
-
Save Interpause/90731e26961b8e528f04a331dedbc1d1 to your computer and use it in GitHub Desktop.
Autostart ADB tunnel for Oculus headset using systemd and udev
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="2833", TAG+="systemd", ENV{SYSTEMD_WANTS}="wivrn-adb-tunnel.service" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So
wivrn-adb-tunnel.shshould go into your/usr/local/bin,wivrn-adb-tunnel.servicegoes into your /etc/systemd/systemand99-oculus-adb.rulesgoes into/etc/udev/rules.d. Make sure to reload systemd service daemonsystemctl daemon-reloadand udev rulesudevadm control --reload-rules`