Created
September 22, 2021 07:44
-
-
Save AnkitSuda/24939c3843330152b2aa8b24af1b2809 to your computer and use it in GitHub Desktop.
Revisions
-
AnkitSuda created this gist
Sep 22, 2021 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ # to run commands as root sudo whoami EMPTY_ADB_OUTPUT="List of devices attached" NO_PERMISSIONS="no permissions" LAST_ADB_OUTPUT="" while true do ADB_OUTPUT=$(adb devices) ADB_OUTPUT="${ADB_OUTPUT%"${ADB_OUTPUT##*[![:space:]]}"}" if [[ "${ADB_OUTPUT}" != "${LAST_ADB_OUTPUT}" ]]; then echo "Changes detected" if [[ "${ADB_OUTPUT}" != "${EMPTY_ADB_OUTPUT}" ]]; then echo "Device connected" if [[ "${ADB_OUTPUT}" != *"${NO_PERMISSIONS}"* ]]; then scrcpy -w -S fi if [[ "${ADB_OUTPUT}" == *"${NO_PERMISSIONS}"* ]]; then echo "No permissions restarting adb server" sudo adb kill-server sudo adb start-server scrcpy -w -S fi fi fi LAST_ADB_OUTPUT="${ADB_OUTPUT}" done