Last active
June 3, 2024 15:22
-
-
Save osfunapps/bf5ced177302e13fd2a2fa387773b7fd to your computer and use it in GitHub Desktop.
Revisions
-
osfunapps revised this gist
Apr 5, 2022 . No changes.There are no files selected for viewing
-
osfunapps revised this gist
Apr 5, 2022 . 1 changed file with 16 additions and 27 deletions.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 @@ -1,20 +1,17 @@ # removefrom quarantine: # sudo xattr -rd com.apple.quarantine "/Users/home/Programming/Python/projects/ToolBoxPy/src/linux/connectPhone.command" # This small script meant to save Apple users the hassle of resetting/disconnecting and connecting an Apple device, again and again, until a steady connection. # Just connect your device and run this command, it will reconnect the device until a steady connection # set here the sensitivity of the checks. I fount it best to use these props MAX_PASSED_CHECKS=50 TIMEOUT_BETWEEN_CHECKS=0.3 # in secs TIMEOUT_AFTER_EACH_USB_RESET=4 # in secs # dynamic variables CHECKS_PASSED=0 # start the checks while true do @@ -25,29 +22,21 @@ do fi echo "---------------------------------------------" echo "**** Checking start..." CHECK_DEVICES_COMMAND=$(system_profiler SPUSBDataType | grep -e iPad -e iPhone) printf "**** Checking done...\n\n" if [ -z "$CHECK_DEVICES_COMMAND" ] then echo "couldn't find device. Resetting USB..." CHECKS_PASSED=0 sudo launchctl stop com.apple.usbd; sudo launchctl start com.apple.usbd echo "Waiting a bit and starting again" sleep $TIMEOUT_AFTER_EACH_USB_RESET else echo "device found! +1 to checks!" CHECKS_PASSED=$((CHECKS_PASSED+1)) fi echo "Number of checks passed: $CHECKS_PASSED/$MAX_PASSED_CHECKS" sleep $TIMEOUT_BETWEEN_CHECKS done exit -
osfunapps renamed this gist
Aug 31, 2021 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
osfunapps created this gist
Aug 31, 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,53 @@ # This small script meant to save Apple users the hassle of resetting/disconnecting and connecting an Apple device, again and again, until a steady connection. # Just connect your device and run this command, it will reconnect the device until a steady connection # set here the sensitivity of the checks. I fount it best to use these props MAX_PASSED_CHECKS=40 TIMEOUT_BETWEEN_CHECKS=0.5 # in secs TIMEOUT_AFTER_EACH_USB_RESET=4 # in secs # dynamic variables CHECKS_PASSED=0 # obtain the currently connected devices DEVICES_COMMAND=$(ioreg -p IOUSB) DEVICES_COUNT_STR=$(echo "$DEVICES_COMMAND" | wc -l) OLD_DEVICES_COUNT=$((DEVICES_COUNT_STR)) # start the checks while true do if [ $CHECKS_PASSED == $MAX_PASSED_CHECKS ] then echo "Device connected!" break fi echo "---------------------------------------------" echo "Checking again..." DEVICES_COMMAND=$(ioreg -p IOUSB) DEVICES_COUNT_STR=$(echo "$DEVICES_COMMAND" | wc -l) CURR_DEVICES_COUNT=$((DEVICES_COUNT_STR)) echo "Old devices count is: $OLD_DEVICES_COUNT" echo "New devices count is: $CURR_DEVICES_COUNT" if [ $OLD_DEVICES_COUNT == $CURR_DEVICES_COUNT ] then echo "Devices have the same size. Increasing checks by one!" CHECKS_PASSED=$((CHECKS_PASSED+1)) else echo "Devices have different size. Resetting checks" CHECKS_PASSED=0 echo "Resetting usb" sudo launchctl stop com.apple.usbd; sudo launchctl start com.apple.usbd echo "Waiting a bit and starting again" sleep $TIMEOUT_AFTER_EACH_USB_RESET fi OLD_DEVICES_COUNT=$CURR_DEVICES_COUNT echo "Number of checks passed: $CHECKS_PASSED/$MAX_PASSED_CHECKS" sleep $TIMEOUT_BETWEEN_CHECKS done exit