Created
March 3, 2020 14:59
-
-
Save halilozercan/e4ac84d5816f367644ecda2aabf51f40 to your computer and use it in GitHub Desktop.
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
| # A shell script to launch scrcpy automatically when a device is connected | |
| # Device name selection is based on lines from `adb devices -l`. | |
| # Script takes a single argument to match any of these lines. | |
| # First matched devices' serial number is used for scrcpy device serial number. | |
| while true | |
| do | |
| # Try to start scrcpy | |
| scrcpy -s $(adb devices -l | awk -v j=$1 'index($0, j);' | awk '{print $1}') | |
| # If scrcpy was closed by user, do not restart until device is replugged in. | |
| if [ $? -eq 0 ]; then | |
| while [ $(adb devices -l | awk -v j=$1 'index($0, j);' | wc -l) -gt 0 ]; do | |
| sleep 0.2 | |
| done | |
| fi | |
| sleep 1 | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment