From b7674788a824a0e813754d227df1de101083c09a Mon Sep 17 00:00:00 2001 From: dece Date: Tue, 5 Jul 2022 12:27:27 +0200 Subject: [PATCH] mount-jmtpfs: improve --- mount-jmtpfs.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/mount-jmtpfs.sh b/mount-jmtpfs.sh index 39521a4..6217b9a 100755 --- a/mount-jmtpfs.sh +++ b/mount-jmtpfs.sh @@ -8,7 +8,7 @@ if ! command -v jmtpfs > /dev/null; then exit fi -if [[ "$1" = "-u" ]]; then +unmount_phones() { for mount_dir in /tmp/jmtpfs.*; do if [ -d "$mount_dir" ]; then umount "$mount_dir" @@ -17,9 +17,19 @@ if [[ "$1" = "-u" ]]; then rm -rI "$mount_dir" fi done - exit -fi +} + +SHOW_MOUNT= +while getopts "hus" OPTION; do + case $OPTION in + h) usage; exit 0 ;; + u) unmount_phones; exit 0 ;; + s) SHOW_MOUNT=true ;; + *) usage; exit 1 ;; + esac +done mount_dir="$(mktemp -d -p /tmp jmtpfs.XXXXXXXXXX)" jmtpfs "$mount_dir" echo "Mount directory: $mount_dir" +[[ "$SHOW_MOUNT" = true ]] && nohup open "$mount_dir" > /dev/null 2>&1