Files
Linux_post_install/apps/media/scrcpy.sh
T
he 5ef38dc46f fix: resolve all 23 MAINTENANCE audit tickets
- deps guards before -h|--help in docker-health/ps, network-scan,
  usb-server, media-mp3/mp4 (--dry-run pre-scan kept); system-firewall
  gains usage()/--help; autostart/usb-automount get flags.sh + template
- install.sh: normalize N-M range syntax in --steps
- bin/pos: INTERACTIVE_CMDS += docker-compose docker-vbox network-hotspot
- common.sh: canonical XDG-aware CONFIG_DIR + DIM color var; notify.sh
  stderr fallback; ent_plugin_* registry renames (runtime plugin API kept)
- docker-compose SCALE_DIR/CONFIG_ENV env seams; ffmpeg in PACKAGES;
  scrcpy.sh exec bit
- docs: health is console-only (--send/--markdown removed), POS.md file
  refs for config/tree/entertainment, DEV.md no-guard exception, docmap/
  filetable regenerated (make gen), hand-maintained line rows bumped
- add scripts/lint-conventions.sh gate + Makefile lint target; record
  all VERIFIED outcomes in MAINTENANCE.md; AGENT_TODO Done entry
  (2026-08-14)
- gates: make gen/check/lint all green (0 FAIL, 0 WARN); bash -n sweep
  clean; restricted-PATH dep tests + step-matrix dry-runs verified
2026-08-14 12:57:00 -04:00

63 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
source "$(dirname "$0")/../../lib/common.sh"
RELEASE_URL="https://api.github.com/repos/Genymobile/scrcpy/releases/latest"
install_scrcpy() {
command -v scrcpy &>/dev/null && { log "scrcpy already installed"; return 0; }
spawn "Fetching latest scrcpy release info" bash -c "
curl -fsSL '$RELEASE_URL' -o /tmp/scrcpy-release.json
"
local tag asset_url
tag=$(python3 -c "import json; print(json.load(open('/tmp/scrcpy-release.json'))['tag_name'])")
asset_url=$(python3 -c "
import json
r = json.load(open('/tmp/scrcpy-release.json'))
for a in r['assets']:
if a['name'].startswith('scrcpy-linux-x86_64') and a['name'].endswith('.tar.gz'):
print(a['browser_download_url'])
break
")
version="${tag#v}"
spawn "Downloading scrcpy $version" bash -c "
install_dir=/usr/local/lib/scrcpy-$version
curl -fsSL '$asset_url' -o /tmp/scrcpy.tar.gz
sudo rm -rf \$install_dir /usr/local/lib/scrcpy
sudo mkdir -p \$install_dir
sudo tar xzf /tmp/scrcpy.tar.gz -C \$install_dir --strip-components=1
sudo ln -sf \$install_dir/scrcpy /usr/local/bin/scrcpy
rm -f /tmp/scrcpy.tar.gz /tmp/scrcpy-release.json
"
spawn "Adding desktop entry" bash -c "
sudo tee /usr/share/applications/scrcpy.desktop >/dev/null <<-EOF
[Desktop Entry]
Name=scrcpy
Comment=Display and control Android devices
Exec=/usr/local/bin/scrcpy
Icon=/usr/local/lib/scrcpy-$version/scrcpy.png
Terminal=false
Type=Application
Categories=Utility;
StartupNotify=false
EOF
"
log "scrcpy $version installed (adb included in the bundle)"
}
uninstall_scrcpy() {
command -v scrcpy &>/dev/null || { log "scrcpy not installed"; return 0; }
spawn "Removing scrcpy files" sudo rm -rf /usr/local/lib/scrcpy-* /usr/local/bin/scrcpy /usr/share/applications/scrcpy.desktop
log "scrcpy removed (bundled adb was removed with it)"
}
case "${1:-}" in
uninstall) uninstall_scrcpy ;;
*) install_scrcpy ;;
esac