summaryrefslogtreecommitdiff
path: root/dmenuumount
diff options
context:
space:
mode:
Diffstat (limited to 'dmenuumount')
-rwxr-xr-xdmenuumount26
1 files changed, 12 insertions, 14 deletions
diff --git a/dmenuumount b/dmenuumount
index 6dc25e2..877bae0 100755
--- a/dmenuumount
+++ b/dmenuumount
@@ -1,45 +1,43 @@
#!/bin/sh
+# Copyright Luke Smith, GPLv3
+# Modified by Zach Smith
# A dmenu prompt to unmount drives.
# Provides you with mounted partitions, select one to unmount.
# 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
-if [ -n "$WAYLAND_DISPLAY" ]; then
- DMENU="tofi"
- DEFARGS="-c $HOME/.config/tofi/themes/dmenu_vertical --prompt-text"
-elif [ -n "$DISPLAY" ]; then
- DMENU="dmenu"
- DEFARGS="-l 15 -p"
-else
- print "Can't tell if Wayland or X; what gives?\n"
- exit 1
-fi
+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 ;;