Skip to content

Commit

Permalink
Support latest homebrew and display no device error (#6)
Browse files Browse the repository at this point in the history
- Add a dialog when no device found
- Skip apple script to avoid automator failure on no input
- Add alternative path for homebrew installation
  • Loading branch information
madlymad authored Oct 25, 2024
1 parent e2c246f commit 0b84bd3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
13 changes: 12 additions & 1 deletion scripts/list_devices.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,15 @@ export PATH=${PATH}:${ANDROID_SDK_HOME}/platform-tools
# adb kill-server
# adb start-server

adb devices | grep -w 'device' | cut -f1 | xargs -I X sh -c 'c=$(adb -s X shell getprop ro.product.manufacturer);m=$(adb -s X shell getprop ro.product.model);s=$(echo X);echo "$s ($c $m)"'
# Get device list with manufacturer and model info
device_list=$(adb devices | grep -w 'device' | cut -f1 | xargs -I X sh -c \
'c=$(adb -s X shell getprop ro.product.manufacturer); m=$(adb -s X shell getprop ro.product.model); s=$(echo X); echo "$s ($c $m)"')

# Check if device_list is empty
if [ -z "$device_list" ]; then
# Show an Automator dialog for no devices found and exit
osascript -e 'display dialog "No devices found. Please connect an Android device and try again." buttons {"Exit"} default button "Exit"' >/dev/null 2>&1
else
# Pass device list to the next step
echo "$device_list"
fi
2 changes: 1 addition & 1 deletion scripts/run_scrcpy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
export ANDROID_SDK_HOME=~/Library/Android/sdk
export PATH=${PATH}:${ANDROID_SDK_HOME}/platform-tools
# Path of scrcpy
export PATH=${PATH}:/usr/local/bin/
export PATH=${PATH}:/usr/local/bin/:/opt/homebrew/bin/

if [[ "$1" == "false" ]]
then
Expand Down
5 changes: 4 additions & 1 deletion scripts/select_device.applescript
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
on run {input, parameters}
if (count of input) is 0 then
return "false"
end if
if (count of input) is 1 then
return input
end if
Expand All @@ -8,6 +11,6 @@ on run {input, parameters}
if answer is not false then
return answer
end if

return "false"
end run

0 comments on commit 0b84bd3

Please sign in to comment.