From 25af7059733a3f5fe0272d5fdb90f7e2faf54f2d Mon Sep 17 00:00:00 2001 From: zachir Date: Fri, 24 Feb 2023 10:27:34 -0600 Subject: add -w and -x flags for dmenu scripts (tofi vs dmenu) --- dmenuumount | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'dmenuumount') diff --git a/dmenuumount b/dmenuumount index 0584cb4..836bded 100755 --- a/dmenuumount +++ b/dmenuumount @@ -4,22 +4,33 @@ # Provides you with mounted partitions, select one to unmount. # Drives mounted at /, /boot and /home will not be options to unmount. +printhelp () { + exit +} + +while getopts "hwxd:" o; do case "${o}" in + w) DMENU="tofi" ;; + x) DMENU="dmenu" ;; + d) ARGS="$ARGS$OPTARG " ;; + *) printhelp ;; +esac done + unmountusb() { [ -z "$drives" ] && exit - chosen="$(echo "$drives" | dmenu -p "Unmount which drive?")" || exit 1 + chosen="$(echo "$drives" | $DMENU $ARGS -p "Unmount which drive?")" || exit 1 chosen="$(echo "$chosen" | awk '{print $1}')" [ -z "$chosen" ] && exit doas umount "$chosen" && notify-send "💻 USB unmounting" "$chosen unmounted." } unmountandroid() { \ - chosen="$(awk '/simple-mtpfs/ {print $2}' /etc/mtab | dmenu -p "Unmount which device?")" || exit 1 + chosen="$(awk '/simple-mtpfs/ {print $2}' /etc/mtab | $DMENU $ARGS -p "Unmount which device?")" || exit 1 [ -z "$chosen" ] && exit doas umount -l "$chosen" && notify-send "🤖 Android unmounting" "$chosen unmounted." } asktype() { \ - choice="$(printf "USB\\nAndroid" | dmenu -p "Unmount a USB drive or Android device?")" || exit 1 + choice="$(printf "USB\\nAndroid" | $DMENU $ARGS -p "Unmount a USB drive or Android device?")" || exit 1 case "$choice" in USB) unmountusb ;; Android) unmountandroid ;; -- cgit v1.2.3