diff --git a/.gitignore b/.gitignore index b601b896..1c7b3cfa 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -*DS_Store \ No newline at end of file +*DS_Store +ios/go-ios diff --git a/README.md b/README.md index 76e0ed9b..58ce8b48 100644 --- a/README.md +++ b/README.md @@ -257,6 +257,11 @@ _Note: This repository is mainly focused on macOS compatibility, but majority of 3. Video footage is saved to ~/Desktop 4. File is compressed using ffmpeg +### 📹 iquicktime +* Run QuickTime and open video source picker (so you can choose a device right away) + * You may have to allow security system permission, so the script can access QuickTime application +* This is a fallback script for `irecord` on M1 macs as it is currently not working + ## Manage applications ### 🚚 iinstall * `iinstall some-app-file.ipa` Install .ipa (make sure to use properly signed build) @@ -268,21 +273,28 @@ _Note: This repository is mainly focused on macOS compatibility, but majority of * `iuninstall -w` Uninstall all third-party packages * Skips some essential apps, edit IGNORED_PACKAGES in this script to customize the list to your needs +### 🚀 ilaunch + * `ilaunch` List third-party apps and choose one to run it + * `ilaunch -s` List os pre-installed apps and choose one to run it + * `ilaunch com.dummy.bundle.id.app` Run app by bundle id + +### 🔪 ikill + * `ikill` List third-party apps and choose one to restart + * `ikill -s` List os pre-installed apps and choose one to restart + * `ikill com.dummy.bundle.id.app` Target specific app by passing bundle id as argument + ## Manage device +### ⚙️ ioptions +* `ioptions` Open system settings application + +### 💬 ilang +* `ilang ` Change the device language to different one, according to ISO-639 (i.e. "cs") +* `ilang` Change the device language to different one, choose from a list of all supported + ### 📜 ilog * `ilog` Print system log output -### 💥 icrashlogs -* `icrashlogs` Import crash logs to ~/Desktop, choose whether to keep them in device storage -* `icrashlogs -k` Import crash logs, keep them in device storage -* `icrashlogs -r` Import crash logs, delete them from device storage -* You can import these logs to Xcode to make them more readable via symbolication - * Open relevant project in Xcode - * Click on Window > Devices and Simulators > View Device Logs - * Drag the .crash file onto the log list - * Readable crash log should appear in the list - ### 📋 icheckdevice * Print device information * (Optional) Search for the device on [GSMArena](https://www.gsmarena.com/ "GSMArena") diff --git a/android/ainstall b/android/ainstall index 79ac10a0..da013e00 100755 --- a/android/ainstall +++ b/android/ainstall @@ -9,7 +9,7 @@ install_app(){ adb -s "$1" install -t -r "$2" &> "$TEMPORARY_FILE" if grep -q Failure "$TEMPORARY_FILE" ; then echo "❌ Installation to $1 failed!" - echo "🤕 Uninstall existing version or troubleshoot the package." + echo "🤕 Uninstall existing version or troubleshoot the package" echo "🔥 Error details: $(grep 'Failure' "$TEMPORARY_FILE" | sed 's/^.*: //')" exit 1 fi diff --git a/android/areboot b/android/areboot index 79b169f4..47adf063 100755 --- a/android/areboot +++ b/android/areboot @@ -3,6 +3,6 @@ LOCATION=$(dirname "$0") source "$LOCATION"/../common_tools android_choose_device -should_proceed "🔌 Do you really want to reboot $SELECTED_DEVICE_MODEL - $SELECTED_DEVICE?" +should_proceed "🔌 Do you really want to reboot - $SELECTED_DEVICE?" echo "🔄 Rebooting the device..." adb -s "$SELECTED_DEVICE" reboot &> /dev/null diff --git a/changelog.txt b/changelog.txt index 4c917ef2..5e720726 100644 --- a/changelog.txt +++ b/changelog.txt @@ -3,10 +3,16 @@ 🌍 https://github.com/IntergalacticPenguin/mobile-toolkit 🆕 Notable changes: - 🚀 Optimized iOS device picker - 🔊 Add atalkback - ✨ Add new iOS device translations + 💣 Using go-ios for all iOS scripts instead of libimobiledevice + (Remove unused tools via `brew uninstall libimobiledevice && brew uninstall ideviceinstaller`) + 🚀 Added ilaunch, ikill, ioption, ilang, atalkback + 🏁 iinstall runs the installed app automatically + 🧟‍♀️ Reintroduce iquicktime as irecord fallback for M1 macs + ⚰️ Removed icrashlogs (perhaps temporarily, depends on go-ios maintainer) + 🩹 Fix Android 12 foreground package detection + ✨ Added new iOS device translations 🚨 Action needed: + 🔐 Ignore the warning about running an untrusted software and enable access in security settings ✨ Make sure to download and install new version of videosnap tool - 🔗 https://github.com/matthutchinson/videosnap/releases/download/v0.0.7/videosnap-0.0.7.pkg + 🔗 https://github.com/matthutchinson/videosnap/releases/download/v0.0.8/videosnap-0.0.8.pkg diff --git a/common_tools b/common_tools index d1d89815..34d27e41 100644 --- a/common_tools +++ b/common_tools @@ -149,7 +149,7 @@ android_is_package_installed() { adb -s "$SELECTED_DEVICE" shell pm list packages -f | sed -e 's/.*=//' | grep -w "$1" &> /dev/null EXIT_CODE=$? if [ $EXIT_CODE -ne 0 ]; then - echo "🤷‍ Package \"$1\" is not installed." + echo "🤷‍ Package \"$1\" is not installed" exit 1 fi } @@ -191,54 +191,98 @@ do ############################################################################## ### iOS +check_go_ios_version(){ + if ! [ -x "$(command -v "go-ios")" ]; then + install_go_ios + else + GO_IOS_VERSION=$(go-ios --version) + #echo "Version of go-ios is: $GO_IOS_VERSION" + fi +} + +install_go_ios(){ + echo "⏳ Installing https://github.com/danielpaulus/go-ios..." + check_dependency "go" + CURRENT_DIR="$PWD" + TOOLKIT_IOS_LOCATION=$(dirname "$0") + git clone "https://github.com/danielpaulus/go-ios.git" "$TOOLKIT_IOS_LOCATION/go-ios" &> /dev/null + cd "$TOOLKIT_IOS_LOCATION/go-ios" + + go build . + chmod +x "go-ios" + mv "go-ios" "go-ios-temp" + mv "go-ios-temp" .. + cd .. + rm -rf "$TOOLKIT_IOS_LOCATION/go-ios" + mv "go-ios-temp" "go-ios" + + cd "$CURRENT_DIR" +} + prompt_xcode_launch(){ echo "❌ Developer image is not mounted and/or device screen is locked" should_proceed "❓ Do you want to open Xcode to fix it? (make sure you have the latest version)" open -a Xcode echo "⏳ Waiting for Xcode to launch..." - sleep 8 + while true ; do + sleep 2 + if [[ $(ps aux | grep -v grep | grep -c Xcode) -ne 0 ]]; then + break + fi + done + sleep 4 + osascript -e 'quit app "Xcode"' } -ios_wait_for_device(){ - echo "⏳ Waiting for iOS device..." - ios_get_devices - while [ ${#IOS_USB_DEVICES[@]} -lt 1 ]; - do - sleep 1 - ios_get_devices - done - delete_lastline +ios_get_devices(){ + check_go_ios_version + check_dependency "jq" + IOS_USB_DEVICES=( $(go-ios list --nojson | sort -u) ) } -ios_check_developer_image_and_pairing(){ - IS_MOUNTED=$(ideviceimagemounter -u "$1" -l) - if [[ $IS_MOUNTED == *"Error"* ]] || [[ $IS_MOUNTED == *"error"* ]] ; then - read -r -p "❌ Device not paired or screen locked - reconnect/unlock it (one at a time) and press ENTER..." - echo "🤝 Requesting pairing..." - idevicepair pair &> /dev/null - read -r -p "❓ Tap \"Trust\" button on the device screen and press ENTER..." - sleep 1 - ios_check_developer_image_and_pairing "$1" +ios_pair_device(){ + go-ios pair --udid="$1" --nojson &> /dev/null + EXIT_CODE=$? + if [ $EXIT_CODE -ne 0 ]; then + read -p "❌ Device is not paired - reconnect it, unlock screen, tap \"Trust\" and press ENTER..." + ios_pair_device "$1" fi +} - if [ ${#IS_MOUNTED} -eq 0 ] ; then +ios_check_pairing(){ + go-ios info --udid="$1" &> "$TEMPORARY_FILE" + if cat "$TEMPORARY_FILE" | grep -q 'UntrustedHostBUID' ; then + read -r -p "❌ Device is not paired - reconnect it, unlock screen, tap \"Trust\" and press ENTER..." + ios_pair_device "$1" + fi + if cat "$TEMPORARY_FILE" | grep -q 'could not retrieve PairRecord' ; then + read -r -p "❌ Device is not paired - reconnect it, unlock screen, tap \"Trust\" and press ENTER..." + ios_pair_device "$1" + fi +} + +ios_check_developer_image(){ + IS_MOUNTED=$((go-ios image list --udid="$1" --nojson) 2>&1) + if [[ $IS_MOUNTED == *"none"* ]]; then prompt_xcode_launch + ios_check_developer_image "$1" fi } +ios_check_developer_image_and_pairing(){ + ios_check_pairing "$1" + ios_check_developer_image "$1" +} + ios_device_info(){ ios_check_developer_image_and_pairing "$1" MANUFACTURER="Apple" - ideviceinfo -s -u "$1" > "$TEMPORARY_FILE" - MODEL=$(ios_translate_name "$(grep "HardwareModel" "$TEMPORARY_FILE" | cut -d\ -f2)") - VERSION=$(grep "ProductVersion" "$TEMPORARY_FILE" | cut -d\ -f2) + go-ios info --udid="$1" > "$TEMPORARY_FILE" + MODEL=$(ios_translate_name "$(cat "$TEMPORARY_FILE" | jq -r '.HardwareModel')") + VERSION=$(cat "$TEMPORARY_FILE" | jq -r '.ProductVersion') INFO=$(printf "%s) %s %s %s - %s" "$NUMBER" "$MANUFACTURER" "$MODEL" "$VERSION" "$ID") } -ios_get_devices(){ - IOS_USB_DEVICES=( $(idevice_id -l | sort -u) ) -} - ios_choose_device(){ check_for_update ios_get_devices @@ -274,9 +318,28 @@ ios_choose_device(){ else SELECTED_DEVICE="${IOS_USB_DEVICES[0]}" fi +} + +ios_get_installed_package_list(){ + echo "⏳ Getting third-party package list..." + INSTALLED_PACKAGES=($(go-ios apps --udid="$1" | jq -r '.[] | .CFBundleIdentifier')) +} + +ios_get_all_package_list(){ + echo "⏳ Getting all package list..." + INSTALLED_PACKAGES=($(go-ios apps --udid="$1" | jq -r '.[] | .CFBundleIdentifier')) + SYSTEM_PACKAGES=($(go-ios apps --udid="$1" --system | jq -r '.[] | .CFBundleIdentifier')) + ALL_PACKAGES=("${INSTALLED_PACKAGES[@]}" "${SYSTEM_PACKAGES[@]}") +} - SELECTED_DEVICE_MODEL=$(ios_translate_name "$(ideviceinfo -u "$SELECTED_DEVICE" | grep "HardwareModel" | cut -d\ -f2)") - SELECTED_DEVICE_VERSION=$(ideviceinfo -u "$SELECTED_DEVICE" | grep "ProductVersion" | cut -d\ -f2) +ios_is_package_installed(){ + ios_get_all_package_list "$SELECTED_DEVICE" + echo "${ALL_PACKAGES[*]}" | grep -w "$1" &> /dev/null + EXIT_CODE=$? + if [ $EXIT_CODE -ne 0 ]; then + echo "🤷‍ Package \"$1\" is not installed" + exit 1 + fi } ios_translate_name(){ @@ -527,7 +590,7 @@ yes_or_no(){ ;; *) echo - echo "🤷‍ Invalid option." + echo "🤷‍ Invalid option" yes_or_no "$1" ;; esac diff --git a/ios/icheckdevice b/ios/icheckdevice index e323dbc4..a70874bc 100755 --- a/ios/icheckdevice +++ b/ios/icheckdevice @@ -2,26 +2,16 @@ LOCATION=$(dirname "$0") source "$LOCATION"/../common_tools ios_choose_device +ios_device_info "$SELECTED_DEVICE" GSM_URL='https://www.gsmarena.com/res.php3?sSearch=' MANUFACTURER=Apple -INFO=$(printf "%s %s - iOS %s" "$MANUFACTURER" "$SELECTED_DEVICE_MODEL" "$SELECTED_DEVICE_VERSION") +INFO=$(printf "%s %s - iOS %s" "$MANUFACTURER" "$MODEL" "$VERSION") -PHONE_URL=$GSM_URL$SELECTED_DEVICE_MODEL +PHONE_URL=$GSM_URL$MODEL -echo "📱 $INFO" -echo " • ID: $SELECTED_DEVICE" - -echo -n "📆 Checking date" -LOCAL_DATE=$(date|cut -f1,2 -d':') -DEVICE_DATE=$(idevicedate -u "$SELECTED_DEVICE"|cut -f1,2 -d':') -if [ "$DEVICE_DATE" != "$LOCAL_DATE" ] -then - echo " - ❗️ Date is set manually" -else - echo " - ✅ OK" -fi +echo "📱 $INFO - ID: $SELECTED_DEVICE" should_proceed "🌐 Search for the device on GSMArena?" open "$PHONE_URL" diff --git a/ios/icrashlogs b/ios/icrashlogs deleted file mode 100755 index 077a1903..00000000 --- a/ios/icrashlogs +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/bash -LOCATION=$(dirname "$0") -source "$LOCATION"/../common_tools -ios_choose_device - -create_folder(){ - DIRNAME=CRASH_LOGS_$SELECTED_DEVICE_MODEL-iOS$SELECTED_DEVICE_VERSION-$(date +%Y-%m-%d-%H-%M-%S) - cd ~/Desktop || exit 1 - mkdir "$DIRNAME" -} - -move_crashlogs(){ - echo "⏳ Moving crash logs to \"~/Desktop/$DIRNAME\", this may take a while..." - idevicecrashreport -u "$SELECTED_DEVICE" "$DIRNAME" &> /dev/null -} - -copy_crashlogs(){ - echo "⏳ Copying crash logs to \"~/Desktop/$DIRNAME\", this may take a while..." - idevicecrashreport -k -u "$SELECTED_DEVICE" "$DIRNAME" &> /dev/null -} - -remove_unrelevant_logs(){ - echo "🔥 Removing unrelevant system logs..." - cd "$DIRNAME" || exit 1 - rm -R -- */ #remove unnecessary system logs - find . -type f ! -name '*.ips' -delete #remove non-crash logs -} - -rename_logs(){ - # Make the logs importable to Xcode - for file in *.ips; do - mv "$file" "$(basename "$file" .ips).crash" &> /dev/null - done -} - -report_sucess_or_remove_folder(){ - if [ -z "$(ls -A)" ]; then - cd .. - rm -rf "$DIRNAME" - echo "❌ No crash logs found!" - else - echo "✅ Crash logs saved to $DIRNAME" - fi -} - -create_folder - -if [[ "$1" == "-r" ]]; then - move_crashlogs -elif [[ "$1" == "-k" ]]; then - copy_crashlogs -else - yes_or_no "🔥 Keep the logs in device storage?" - if [[ "$RESPONSE" == "n" || "$RESPONSE" == "N" ]]; then - move_crashlogs - else - copy_crashlogs - fi -fi - -remove_unrelevant_logs -rename_logs -report_sucess_or_remove_folder diff --git a/ios/iinstall b/ios/iinstall index 2eec583e..d056718c 100755 --- a/ios/iinstall +++ b/ios/iinstall @@ -6,14 +6,27 @@ source "$LOCATION"/../common_tools install_app(){ echo "⌛️ Installing \"$2\" to $1..." TEMPORARY_FILE="$TEMPORARY_FILE-$(date +%s)" - ideviceinstaller -u "$1" -i "$2" &> "$TEMPORARY_FILE" - if grep -q ERROR "$TEMPORARY_FILE" ; then + go-ios install --udid="$1" --path="$PWD/$2" &> "$TEMPORARY_FILE" + if grep -q 'err' "$TEMPORARY_FILE" ; then echo "❌ Installation to $1 failed!" - echo "🤕 Uninstall existing version or troubleshoot the package." - echo "🔥 Error details: $(grep 'ERROR' "$TEMPORARY_FILE" | sed 's/^.*: //')" + echo "🤕 Uninstall existing version or troubleshoot the package" + echo "🔥 Error details: $(grep 'err' "$TEMPORARY_FILE" | jq -r '.err')" exit 1 fi echo "✅ Successfully installed to $1" + run_app "$1" "$PWD/$2" +} + +run_app(){ + echo "🚀 Launching \"$BUNDLE_ID\" on $1..." + TEMPORARY_FILE="$TEMPORARY_FILE-$(date +%s)" + go-ios launch "$BUNDLE_ID" --udid="$1" &> "$TEMPORARY_FILE" + if grep -q 'err' "$TEMPORARY_FILE" ; then + echo "❌ App launch failed!" + echo "🤕 Check if developer certificate is trusted in Settings" + echo "🔥 Error details: $(grep 'error' "$TEMPORARY_FILE" | jq -r '.error')" + exit 1 + fi } check_args_valid(){ @@ -32,10 +45,23 @@ check_args_valid(){ fi } +get_bundle_id(){ + echo "🔍 Detecting bundle ID..." + unzip "$1" &> /dev/null + APP_FILENAME=$(ls "$PWD"/Payload) + BUNDLE_ID=$(grep "$PWD/Payload/$APP_FILENAME/embedded.mobileprovision" -a -e "[.]com[.]" | sed 's/.[^.]*\.//' | sed 's/\<.*$//') + if [[ "$BUNDLE_ID" == "" ]]; then # Fallback for bundle identifiers containing "app" instead of "com" + BUNDLE_ID=$(grep "$PWD/Payload/$APP_FILENAME/embedded.mobileprovision" -a -e "[.]app[.]" | sed 's/.[^.]*\.//' | sed 's/\<.*$//') + fi + BUNDLE_ID=$(echo "$BUNDLE_ID" | head -n 1) + rm -rf "$PWD/Payload" +} + run(){ if [[ $1 == "-a" ]]; then check_for_update ios_get_devices + get_bundle_id "$2" for ID in "${IOS_USB_DEVICES[@]}" do install_app "$ID" "$2" & @@ -43,10 +69,10 @@ run(){ wait else ios_choose_device + get_bundle_id "$1" install_app "$SELECTED_DEVICE" "$1" fi } -check_dependency "ideviceinstaller" check_args_valid "$@" run "$@" diff --git a/ios/ikill b/ios/ikill new file mode 100755 index 00000000..aa7412f4 --- /dev/null +++ b/ios/ikill @@ -0,0 +1,40 @@ +#!/bin/bash +LOCATION=$(dirname "$0") +source "$LOCATION"/../common_tools +ios_choose_device + +if [[ "$1" == "-s" ]]; then + PACKAGES=($(go-ios apps --udid="$SELECTED_DEVICE" --system | jq -r '.[] | .CFBundleIdentifier')) +elif [[ -n "$1" ]]; then + PACKAGE="$1" + ios_is_package_installed "$PACKAGE" +else + PACKAGES=($(go-ios apps --udid="$SELECTED_DEVICE" | jq -r '.[] | .CFBundleIdentifier')) +fi + +if [ -z "$PACKAGE" ]; then + PACKAGES_LISTED=() + for P in "${PACKAGES[@]}" #removes trailing \r + do + P=${P%$'\r'} + PACKAGES_LISTED+=("$P") + done + + if [ ${#PACKAGES_LISTED[@]} -eq 0 ]; then + echo "🤷‍ No third-party apps installed, use \"alaunch -s\" to list system packages" + exit 1 + fi + + echo "📋 Choose application to kill:" + select OPTION in "${PACKAGES_LISTED[@]}" + do + case $OPTION in + *) PACKAGE=$OPTION;break; ;; + esac + done +fi + +echo "🔪 Killing $PACKAGE..." +go-ios kill "$PACKAGE" --udid="$SELECTED_DEVICE" &> /dev/null +echo "🚀 Relaunching the app..." +go-ios launch "$PACKAGE" &> /dev/null diff --git a/ios/ilang b/ios/ilang new file mode 100755 index 00000000..6eb4dbbf --- /dev/null +++ b/ios/ilang @@ -0,0 +1,26 @@ +#!/bin/bash +LOCATION=$(dirname "$0") +source "$LOCATION"/../common_tools +ios_choose_device +LANGUAGES=( "en" "cs" "sk" "ar" "ca" "hr" "da" "nl" "en-GB" "fi" "fr" "de" "el" "he" "hi" "hu" "id" "it" "ja" "ko" "ms" "nb" "pl" "pt" "pt-BR" "ro" "ru" "es" "sv" "th" "tr" "uk" "vi") + +if [ -n "$1" ]; then + LANG="$1" +else + echo "📋 Choose desired language:" + select OPTION in "${LANGUAGES[@]}" + do + case $OPTION in + *) LANG=$OPTION;break; ;; + esac + done +fi + +echo "💬 Setting language to \"$LANG\" (it might take a while)..." +go-ios lang --udid="$SELECTED_DEVICE" --setlang="$LANG" &> /dev/null + +EXIT_CODE=$? +if [ $EXIT_CODE -ne 0 ]; then + echo "🤷‍ Supplied language \"$1\" is not supported" + exit 1 +fi diff --git a/ios/ilaunch b/ios/ilaunch new file mode 100755 index 00000000..a44dbb55 --- /dev/null +++ b/ios/ilaunch @@ -0,0 +1,38 @@ +#!/bin/bash +LOCATION=$(dirname "$0") +source "$LOCATION"/../common_tools +ios_choose_device + +if [[ "$1" == "-s" ]]; then + PACKAGES=($(go-ios apps --udid="$SELECTED_DEVICE" --system | jq -r '.[] | .CFBundleIdentifier')) +elif [[ -n "$1" ]]; then + PACKAGE="$1" + ios_is_package_installed "$PACKAGE" +else + PACKAGES=($(go-ios apps --udid="$SELECTED_DEVICE" | jq -r '.[] | .CFBundleIdentifier')) +fi + +if [ -z "$PACKAGE" ]; then + PACKAGES_LISTED=() + for P in "${PACKAGES[@]}" #removes trailing \r + do + P=${P%$'\r'} + PACKAGES_LISTED+=("$P") + done + + if [ ${#PACKAGES_LISTED[@]} -eq 0 ]; then + echo "🤷‍ No third-party apps installed, use \"alaunch -s\" to list system packages" + exit 1 + fi + + echo "📋 Choose application to launch:" + select OPTION in "${PACKAGES_LISTED[@]}" + do + case $OPTION in + *) PACKAGE=$OPTION;break; ;; + esac + done +fi + +echo "🚀 Launching \"$PACKAGE\"..." +go-ios launch "$PACKAGE" --udid="$SELECTED_DEVICE" &> /dev/null diff --git a/ios/ilog b/ios/ilog index d020ff9f..ef1e2df8 100755 --- a/ios/ilog +++ b/ios/ilog @@ -4,4 +4,4 @@ source "$LOCATION"/../common_tools ios_choose_device echo "📜 Device log:" -idevicesyslog "$SELECTED_DEVICE" +go-ios syslog --udid="$SELECTED_DEVICE" --nojson diff --git a/ios/ioptions b/ios/ioptions new file mode 100755 index 00000000..9b4bcbd2 --- /dev/null +++ b/ios/ioptions @@ -0,0 +1,7 @@ +#!/bin/bash +LOCATION=$(dirname "$0") +source "$LOCATION"/../common_tools +ios_choose_device + +echo "🔨 Launching system settings..." +go-ios launch "com.apple.Preferences" --udid="$SELECTED_DEVICE" &> /dev/null diff --git a/ios/iquicktime b/ios/iquicktime new file mode 100755 index 00000000..385eecff --- /dev/null +++ b/ios/iquicktime @@ -0,0 +1,13 @@ +#!/bin/bash +echo "📹 Opening QuickTime..." + +osascript < /dev/null +go-ios reboot --udid="$SELECTED_DEVICE" &> /dev/null diff --git a/ios/irecord b/ios/irecord index 5da06740..c6ea924a 100755 --- a/ios/irecord +++ b/ios/irecord @@ -37,14 +37,14 @@ EOD pick_recording_device(){ ios_choose_device ios_device_info "$SELECTED_DEVICE" - DEVICE_NAME=$(idevicename -u "$SELECTED_DEVICE") + DEVICE_NAME=$(go-ios devicename --udid="$SELECTED_DEVICE" --nojson) FILENAME="$MANUFACTURER-$MODEL-iOS$VERSION-$(date +%Y-%m-%d-%H-%M-%S).mp4" } start_recording(){ RECORDING=true echo "📹 Recording screen on $SELECTED_DEVICE ($DEVICE_NAME), stop it using ctrl^c" - videosnap -w 0 --no-audio -p High -d "$DEVICE_NAME" "$FILENAME" &> /dev/null + videosnap -p High -d "$DEVICE_NAME" "$FILENAME" &> /dev/null } compress_video(){ @@ -59,6 +59,13 @@ compress_video(){ fi } +if uname -m | grep -q arm64 ; then + echo "🤕 This script is currently not working on M1 based macs" + echo "🔗 See https://github.com/matthutchinson/videosnap/issues/24" + echo "🩹 You can use \"iquicktime\" temporarily instead" + exit 1 +fi + check_videosnap_dependency check_dependency "ffmpeg" diff --git a/ios/iscreenshot b/ios/iscreenshot index 36222386..ea08f71b 100755 --- a/ios/iscreenshot +++ b/ios/iscreenshot @@ -2,18 +2,15 @@ trap "kill 0" SIGINT # Kill all spawned subprocesses on ctrl^c LOCATION=$(dirname "$0") source "$LOCATION"/../common_tools -cd ~/Desktop || exit screenshot(){ ios_device_info "$1" FILENAME="$MANUFACTURER-$MODEL-iOS$VERSION-$(date +%Y-%m-%d-%H-%M-%S).png" echo "📸 Saving screenshot into $FILENAME..." - idevicescreenshot -u "$1" "$FILENAME" &> /dev/null + go-ios screenshot --udid="$1" --output="$HOME/Desktop/$FILENAME" &> /dev/null EXIT_CODE=$? if [ $EXIT_CODE -ne 0 ]; then echo "🤷 Screenshot failed, error code: $EXIT_CODE" - prompt_xcode_launch - screenshot "$1" fi } diff --git a/ios/iuninstall b/ios/iuninstall index c0b477ce..2136bce6 100755 --- a/ios/iuninstall +++ b/ios/iuninstall @@ -2,52 +2,13 @@ trap "kill 0" SIGINT # Kill all spawned subprocesses on ctrl^c LOCATION=$(dirname "$0") source "$LOCATION"/../common_tools +IGNORED_PACKAGES=( "com.apple.TestFlight" "motif.FramerPreview" "com.figma.FigmaMirror" "com.invisionapp.InVisionApp-iOS" "com.8bit.bitwarden" ) +ios_choose_device -init(){ - check_dependency "ideviceinstaller" - IGNORED_PACKAGES=( "com.apple.TestFlight" "motif.FramerPreview" "com.figma.FigmaMirror" "com.invisionapp.InVisionApp-iOS" "com.8bit.bitwarden" ) -} - -ios_get_package_list(){ - echo "⏳ Getting third-party package list..." - PACKAGE_LIST=() - ALL_INFO_LIST=($(ideviceinstaller -u "$SELECTED_DEVICE" -l -o list_user | tail -n +2 | sed -e 's/.*=//' | sort)) - - for PACKAGE in "${ALL_INFO_LIST[@]}" #remove redundant information - do - echo "$PACKAGE" | grep -q '"' - EXIT_CODE=$? - - if [ $EXIT_CODE -ne 0 ]; then - PACKAGE=${PACKAGE%,*} - PACKAGE_LIST+=("$PACKAGE") - fi - done - - if [ ${#PACKAGE_LIST[@]} -eq 0 ]; then - echo "🤷‍ No packages installed." - exit - fi -} - -filter_packages(){ - PACKAGES_FILTERED=() - for PKG in "${PACKAGE_LIST[@]}" #removes trailing \r - do - PKG=${PKG%$'\r'} - echo "${IGNORED_PACKAGES[*]}" | grep -w "$PKG" &> /dev/null && { echo "⏩ Skipped \"$PKG\""; continue; } - PACKAGES_FILTERED+=("$PKG") - done - - if [ ${#PACKAGES_FILTERED[@]} -eq 0 ]; then - echo "🤷‍ Nothing to uninstall" - exit - fi -} select_option(){ echo "📋 Choose package number:" - select OPTION in "${PACKAGES_FILTERED[@]}" + select OPTION in "${INSTALLED_PACKAGES[@]}" do case $OPTION in *) PACKAGE=$OPTION;break; ;; @@ -61,19 +22,19 @@ select_option(){ uninstall_package(){ PACKAGE="$1" - echo "${PACKAGE_LIST[*]}" | grep -w "$PACKAGE" &> /dev/null || { echo "🤷‍ Package \"$PACKAGE\" not installed"; return 1; } + echo "${INSTALLED_PACKAGES[*]}" | grep -w "$PACKAGE" &> /dev/null || { echo "🤷‍ Package \"$PACKAGE\" not installed"; return 1; } echo "${IGNORED_PACKAGES[*]}" | grep -w "$PACKAGE" &> /dev/null && { echo "❌ Package \"$PACKAGE\" is whitelisted"; return 1; } echo "🔥 Uninstalling \"$PACKAGE\"..." - ideviceinstaller -u "$SELECTED_DEVICE" -U "$PACKAGE" &> /dev/null + go-ios uninstall --udid="$SELECTED_DEVICE" "$PACKAGE" &> /dev/null return 0 } uninstall_all(){ tput setaf 1 - should_proceed "💣 Delete all third-party apps on $SELECTED_DEVICE_MODEL - $SELECTED_DEVICE?" + should_proceed "💣 Delete all third-party apps on $SELECTED_DEVICE?" tput sgr0 - for PKG in "${PACKAGE_LIST[@]}" + for PKG in "${INSTALLED_PACKAGES[@]}" do uninstall_package "$PKG" & done @@ -88,18 +49,16 @@ handle_arguments(){ fi if [ -z "$1" ]; then - if [ ${#PACKAGE_LIST[@]} -eq 0 ]; then + if [ ${#INSTALLED_PACKAGES[@]} -eq 0 ]; then echo "🤷‍ Nothing to uninstall" exit fi - filter_packages select_option uninstall_package "$PACKAGE" fi } -ios_choose_device -init -ios_get_package_list + +ios_get_installed_package_list "$SELECTED_DEVICE" handle_arguments "$@" echo "✅ Done"