Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TechnoSparks/948e62408286436eb0fd10dc403381c8 to your computer and use it in GitHub Desktop.
Save TechnoSparks/948e62408286436eb0fd10dc403381c8 to your computer and use it in GitHub Desktop.

Use Android on PC but with desktop mode using scrcpy

#!/usr/bin/env bash
# IP address of android device
adbip='192.168.1.101:2109'
# resolution/dpi of second screen
resdpi='1920x1000/180'
# args to pass for scrcpy
scrcpyargs='-S -b 16M --power-off-on-close --video-codec=h265 -K -w'
errorf() {
echo "Error occured."
read -p "Press any key to continue"
exit
}
echo Connect via WADB
adb connect $adbip || errorf
echo Spawning second display
adb shell settings put global overlay_display_devices $resdpi || errorf
echo Identifying display ID
id=$(scrcpy.exe --list-displays | awk -F '=' '/display-id/ && ++count == 2 {split($2, id, /[[:space:]]/); print id[1]}')
scrcpy $scrcpyargs --display-id $id || errorf
echo Destroying second display
adb shell settings put global overlay_display_devices none || errorf
@echo off
nircmd exec hide busybox bash launch.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment