summaryrefslogtreecommitdiff
path: root/dmenumount
diff options
context:
space:
mode:
Diffstat (limited to 'dmenumount')
-rwxr-xr-xdmenumount23
1 files changed, 17 insertions, 6 deletions
diff --git a/dmenumount b/dmenumount
index af6c390..91b0827 100755
--- a/dmenumount
+++ b/dmenumount
@@ -5,19 +5,30 @@
# be prompted to give a mountpoint from already existsing directories. If you
# input a novel directory, it will prompt you to create that directory.
+printhelp () {
+ exit
+}
+
+while getopts "wxhd:" o; do case "${o}" in
+ w) DMENU="tofi" ;;
+ x) DMENU="dmenu" ;;
+ d) ARGS="$ARGS$OPTARG " ;;
+ *) printhelp ;;
+esac done
+
getmount() { \
[ -z "$chosen" ] && exit 1
# shellcheck disable=SC2086
- mp="$(find $1 2>/dev/null | dmenu -p "Type in mount point.")" || exit 1
+ mp="$(find $1 2>/dev/null | $DMENU $ARGS -p "Type in mount point.")" || exit 1
test -z "$mp" && exit 1
if [ ! -d "$mp" ]; then
- mkdiryn=$(printf "No\\nYes" | dmenu -p "$mp does not exist. Create it?") || exit 1
+ mkdiryn=$(printf "No\\nYes" | $DMENU $ARGS -p "$mp does not exist. Create it?") || exit 1
[ "$mkdiryn" = "Yes" ] && (mkdir -p "$mp" || doas mkdir -p "$mp")
fi
}
mountusb() { \
- chosen="$(echo "$usbdrives" | dmenu -p "Mount which drive?")" || exit 1
+ chosen="$(echo "$usbdrives" | $DMENU $ARGS -p "Mount which drive?")" || exit 1
chosen="$(echo "$chosen" | awk '{print $1}')"
echo "$chosen"
doas mount "$chosen" 2>/dev/null && notify-send "💻 USB mounting" "$chosen mounted." && exit 0
@@ -33,17 +44,17 @@ mountusb() { \
}
mountandroid() { \
- chosen="$(echo "$anddrives" | dmenu -p "Which Android device?")" || exit 1
+ chosen="$(echo "$anddrives" | $DMENU $ARGS -p "Which Android device?")" || exit 1
chosen="$(echo "$chosen" | cut -d : -f 1)"
getmount "$HOME -maxdepth 3 -type d"
simple-mtpfs --device "$chosen" "$mp"
- echo "OK" | dmenu -p "Tap Allow on your phone if it asks for permission and then press enter" || exit 1
+ echo "OK" | $DMENU $ARGS -p "Tap Allow on your phone if it asks for permission and then press enter" || exit 1
simple-mtpfs --device "$chosen" "$mp"
notify-send "🤖 Android Mounting" "Android device mounted to $mp."
}
asktype() { \
- choice="$(printf "USB\\nAndroid" | dmenu -p "Mount a USB drive or Android device?")" || exit 1
+ choice="$(printf "USB\\nAndroid" | $DMENU $ARGS -p "Mount a USB drive or Android device?")" || exit 1
case $choice in
USB) mountusb ;;
Android) mountandroid ;;