-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathandroidmirror
More file actions
executable file
·39 lines (30 loc) · 852 Bytes
/
androidmirror
File metadata and controls
executable file
·39 lines (30 loc) · 852 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env bash
set -euo pipefail
SERIAL="${ANDROID_SERIAL:-}"
SCRCPY_OPTS=(-d --max-fps 60 --stay-awake --turn-screen-off --no-window-border --window-width 1100 --crop 1080:1800:0:200)
restart_adb() {
adb kill-server >/dev/null 2>&1 || true
pkill -x adb 2>/dev/null || true
adb start-server >/dev/null
}
usb_seen() {
system_profiler SPUSBDataType | grep -qiE 'samsung|android|pixel|google|phone'
}
adb_seen() {
adb devices | awk 'NR>1 && $2=="device" {print $1}' | grep -q .
}
main() {
restart_adb
if ! usb_seen; then
echo "Phone not visible on USB bus." >&2
exit 1
fi
if ! adb_seen; then
echo "Phone visible on USB, but not in adb." >&2
echo "Try: unlock phone, set USB mode to File Transfer, toggle USB debugging." >&2
exit 2
fi
adb devices -l >&2
exec scrcpy "${SCRCPY_OPTS[@]}"
}
main "$@"