Welcome to SparkyLinux forums
Zapraszamy również na polsko-języczne Forum https://forum.linuxiarze.pl

Scrcpy: your android device on desktop via adb

Started by jidan, October 13, 2019, 10:16:17 PM

Previous topic - Next topic

jidan

A common problem with android versions > 6 is the remote desktop, as the good-old onaips droid-vnc server doesn't work anymore. All replacements are commercial and too slow to use.
Looking for something better and free, i found a python app with the odd name "scrcpy" (stands for "screen copy") licenced under Apache License 2.0. Using the adb connection you don't need to root your android device or install third party apps. Just install the app on your linux desktop and allow usb debugging on android. It's reliable and extremely fast (30-60fps!!). I can even watch movies played in android on my sparky desktop.
The last version 1.10 is checked on android 7,8,9 and sparky oldstable and stable x86 and 64.

To install it on debian you have to compile by yourself a part of it. There's also a snap package named "scrcpy" but there are many reasons to avoid snap. Just follow the steps:

1. Install dependencies:

sudo apt install adb ffmpeg libsdl2-2.0.0 make gcc pkg-config meson ninja-build libavcodec-dev libavformat-dev libavutil-dev libsdl2-dev


2. Download the pre-compiled server and install on your system

wget https://github.com/Genymobile/scrcpy/releases/download/v1.10/scrcpy-server-v1.10.jar
sudo install scrcpy-server-v1.10.jar /usr/local/bin/scrcpy-server.jar


3.Download the source (or clone the github folder)

wget https://github.com/Genymobile/scrcpy/archive/v1.10.zip


4. unzip and rename folder to "scrcpy"

5. cd to scrcpy and build:

cd scrcpy
meson build --buildtype release --strip -Db_lto=true  -Dprebuilt_server=../scrcpy-server-v1.10.jar
cd build
ninja
sudo ninja install


For full description: https://github.com/Genymobile/scrcpy

After a successful installation just adb connect your device, via usb cable or tcpip and run scrcpy. Your android desktop appears in a lovely window on your desktop. More options for scrcpy at its github.

Even further, we can create a yad script to control our devices, something like that (for tcp/ip connections) :

args=$(yad --center --top --borders=20 --width=200 --title "Scrcpy ADB Remote" --image="/path/to/icon/android-masked_64-1.png" --form --field="IP" 192.168.0.|^192.168.1.|192.168.2. --field="Bit Rate":CBE 1K!10K!^2M!5M --field="Max Size":CBE 600!800!^1080)
ip=$(echo $args | awk -F '|' '{print $1}')
br0=$(echo $args | awk -F '|' '{print $2}')
ms0=$(echo $args | awk -F '|' '{print $3}')
if [ -z "$ip" ]; then exit 0
fi
if [ ! -z "$br0" ]; then br=" --bit-rate $br0"
fi
if [ ! -z "$ms0" ]; then ms=" --max-size $ms0"
fi
adb connect $ip &&
scrcpy$br$ms &&
adb kill-server


and some funny icons i use as desktop icon and in yad window:




I think it's a useful app to include as scripts to the mobile-friendly sparky apps.

View the most recent posts on the forum