Last active
March 25, 2025 03:16
-
-
Save sming/8204721f0063bf8c937dcede32139f65 to your computer and use it in GitHub Desktop.
Dead-simple M[1-N] MacOS shell script that makes a second attempt to start scrcpy as for me, the first attempt nearly always fails. For Raycast but works as standalone.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Required parameters: | |
# @raycast.schemaVersion 1 | |
# @raycast.title scrcpy | |
# @raycast.mode inline | |
# Optional parameters: | |
# @raycast.icon 🤖 | |
# @raycast.packageName org.psk.raycast | |
# Documentation: | |
# @raycast.description run scrcpy | |
# @raycast.author Peter Kingswell | |
# @raycast.authorURL https://github.com/sming | |
export PATH=/opt/homebrew/bin:$PATH # just in case scrcpy is not on $PATH | |
echo "scrcpy-ing..." | |
scrcpy --no-audio --stay-awake --screen-off-timeout=240 --capture-orientation 0 # --stay-awake only applies when plugged in, and don't rotate it else shit gets weird | |
retVal=$? | |
# If this one didn't work, which is often, then try again | |
if [ $retVal -ne 0 ]; then | |
echo "Retrying - restarting adb server..." | |
adb kill-server && adb start-server | |
echo "...server restarted, making attempt #2" | |
scrcpy --no-audio --stay-awake --screen-off-timeout=240 --capture-orientation 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment