fix: raise error when android not mounted

This commit is contained in:
Inlife 2022-11-12 18:09:21 +01:00 committed by GitHub
parent d6616cf08b
commit 655c9ffcf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,13 +31,19 @@ mountusb() { \
notify-send "💻 USB mounting" "$chosen mounted to $mp." notify-send "💻 USB mounting" "$chosen mounted to $mp."
} }
androidcrash() { \
notify-send "🚫 Error" "Failed to mount Android device to $mp."
namei -l "$mp" | sed '1d' | awk '{ print $2 }' | grep $(whoami) || notify-send "⚠️ Error complement" "You probably chose a directory for which you do not have the rights"
exit 1
}
mountandroid() { \ mountandroid() { \
chosen="$(echo "$anddrives" | dmenu -i -p "Which Android device?")" || exit 1 chosen="$(echo "$anddrives" | dmenu -i -p "Which Android device?")" || exit 1
chosen="$(echo "$chosen" | cut -d : -f 1)" chosen="$(echo "$chosen" | cut -d : -f 1)"
getmount "$HOME -maxdepth 3 -type d" getmount "$HOME -maxdepth 3 -type d"
simple-mtpfs --device "$chosen" "$mp" simple-mtpfs --device "$chosen" "$mp"
echo "OK" | dmenu -i -p "Tap Allow on your phone if it asks for permission and then press enter" || exit 1 echo "OK" | dmenu -i -p "Tap Allow on your phone if it asks for permission and then press enter" || exit 1
simple-mtpfs --device "$chosen" "$mp" simple-mtpfs --device "$chosen" "$mp" || androidcrash
notify-send "🤖 Android Mounting" "Android device mounted to $mp." notify-send "🤖 Android Mounting" "Android device mounted to $mp."
} }