Skip to content

Instantly share code, notes, and snippets.

@stefan-matic
Last active January 27, 2021 11:58
Show Gist options
  • Save stefan-matic/d8a05a77bcbfcc001b19d263156973f3 to your computer and use it in GitHub Desktop.
Save stefan-matic/d8a05a77bcbfcc001b19d263156973f3 to your computer and use it in GitHub Desktop.
Android remote control with scrcpy

You need scrcpy and adb

https://github.com/Genymobile/scrcpy

You need to enable ADB debugging (USB and WiFi) Depending on your phone this can have different naming conventions.

I set it up first normally with scrcpy via USB for testing, and then I use the script above. Be sure to replace <PHONE_IP> with your usual phone's local home IP (e.g. adb connect 192.168.1.120)

You can place the script in your path so you can run it globally in your terminal.

Script only tested on Ubuntu.

#!/bin/bash
adb kill-server
adb tcpip 5555
read -r -p " Are you home? [Y/n] " response
case $response in
[yY][eE][sS]|[yY]|"" )
echo "Connecting to phone..."
adb connect <PHONE_IP>
scrcpy
;;
[nN][oO]|[nN])
read -e -p "What is the device IP?" ip
adb connect $ip
scrcpy
;;
*)
echo "Invalid input..."
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment