summaryrefslogtreecommitdiff
path: root/dmenuumount
diff options
context:
space:
mode:
Diffstat (limited to 'dmenuumount')
-rwxr-xr-xdmenuumount16
1 files changed, 10 insertions, 6 deletions
diff --git a/dmenuumount b/dmenuumount
index 59383f1..877bae0 100755
--- a/dmenuumount
+++ b/dmenuumount
@@ -7,33 +7,37 @@
# Drives mounted at /, /boot and /home will not be options to unmount.
printhelp () {
+ printf "dmenuumount: dmenu prompt to unmount drives\n"
+ printf "dmenuumount [-d X]\n"
+ printf "\t-d X) pass X as an arg to dmenu\n"
exit
}
while getopts "hd:" o; do case "${o}" in
- d) ARGS="$ARGS$OPTARG " ;;
+ d) ARG=${ARG:+"$ARG "}"$OPTARG" ;;
*) printhelp ;;
esac done
-DMENU="dmenu"
-DEFARGS="-l 15 -p"
+dmenu_lp () {
+ dmenu -l 15 -p "$@"
+}
unmountusb() {
[ -z "$drives" ] && exit
- chosen="$(echo "$drives" | $DMENU $DEFARGS "Unmount which drive?" $ARGS)" || exit 1
+ chosen="$(echo "$drives" | dmenu_lp "Unmount which drive?" ${ARG:+"$ARG"})" || exit 1
chosen="$(echo "$chosen" | awk '{print $1}')"
[ -z "$chosen" ] && exit
sudo umount "$chosen" && notify-send "💻 USB unmounting" "$chosen unmounted."
}
unmountandroid() { \
- chosen="$(awk '/simple-mtpfs/ {print $2}' /etc/mtab | $DMENU $DEFARGS "Unmount which device?" $ARGS )" || exit 1
+ chosen="$(awk '/simple-mtpfs/ {print $2}' /etc/mtab | dmenu_lp "Unmount which device?" ${ARG:+"$ARG"} )" || exit 1
[ -z "$chosen" ] && exit
sudo umount -l "$chosen" && notify-send "🤖 Android unmounting" "$chosen unmounted."
}
asktype() { \
- choice="$(printf "USB\\nAndroid" | $DMENU $DEFARGS "Unmount a USB drive or Android device?" $ARGS)" || exit 1
+ choice="$(printf "USB\\nAndroid" | dmenu_lp "Unmount a USB drive or Android device?" ${ARG:+"$ARG"})" || exit 1
case "$choice" in
USB) unmountusb ;;
Android) unmountandroid ;;