reapk 881 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/zsh
  2. [ -f "$HOME/.config/norisa/reapk" ] || exit 1
  3. notify() {
  4. echo "$1"
  5. notify-send "ReAPK" "$1"
  6. }
  7. # check if access to file
  8. apkFile=$(cat "$HOME/.config/norisa/reapk")
  9. fileTest=$(file $apkFile)
  10. if echo $fileTest | grep -q "Error: cannot open APK file"; then
  11. notify "error"
  12. fi
  13. #select device
  14. deviceAmount=$(adb devices | wc -l)
  15. if [ "$deviceAmount" -lt 3 ]; then
  16. notify "Error: cannot open any devices"
  17. exit 1
  18. elif [ "$deviceAmount" -eq 3 ]; then
  19. extraAPKoptions=""
  20. else
  21. device=$(adb devices -l | sed '/List of devices/d; /^$/d' | dmenu -i -l 30 -p "Selet Device:" | awk '{print $1}')
  22. if [ -z $device ]; then
  23. notify "Error: no device selected"
  24. exit 1
  25. fi
  26. extraAPKoptions="-s $device"
  27. fi
  28. # install and notify when action finished
  29. st-exec "adb install $extraAPKoptions -r $apkFile" && notify "Action Finished !!!"