Aug 17,
2023

Installing scrcpy with Stow

Greetings terminal dwellers!

Scrcpy lets you display and control Android devices from your desktop over USB or TCP/IP. No root required, minimal latency, works over adb.

Debian ships it, but packages lag behind releases. I build from source and manage with Stow.

Getting the prebuilt server

Scrcpy has two parts: desktop client (what you build) and Android server (prebuilt APK). Download the server binary first:

wget https://github.com/Genymobile/scrcpy/releases/download/v2.2.1/scrcpy-server-v2.2.1

Building with Meson

Extract source, then configure with Meson. Key detail: --prefix=/ not --prefix=/usr/local. Stow handles the prefix via DESTDIR:

meson setup build --buildtype release --strip -Db_lto=true \
    -Dprebuilt_server=scrcpy-server-v2.2.1 --prefix=/

Build flags: release mode, stripped binaries, LTO for smaller size. Point to downloaded server binary.

Compile:

ninja -C build

Installing to Stow directory

Install to version-specific Stow directory instead of system paths:

DESTDIR=/usr/local/stow/scrcpy-2.2.1 ninja -C build install

This creates /usr/local/stow/scrcpy-2.2.1/bin/scrcpy, /usr/local/stow/scrcpy-2.2.1/share/scrcpy/*, etc.

Activate with Stow:

cd /usr/local/stow
sudo stow scrcpy-2.2.1

Symlinks created in /usr/local/bin, /usr/local/share, pointing to Stow directory.

Uninstalling

Remove symlinks:

cd /usr/local/stow
sudo stow -D scrcpy-2.2.1

Delete directory when done:

sudo rm -rf /usr/local/stow/scrcpy-2.2.1

If server path isn't found

Sometimes scrcpy can't locate the server binary. Set the path manually:

export SCRCPY_SERVER_PATH=/usr/local/share/scrcpy/scrcpy-server
scrcpy

Or add to shell rc file for persistence.

Why bother

Distro packages work fine. But building from source means latest features and bug fixes. Stow keeps /usr/local clean—multiple versions coexist peacefully. Upgrades are symmetric: build new version, stow it, stow -D the old one.

Is it necessary? No. Is compiling software more satisfying than apt install? Absolutely. Even when it doesn't matter.