dmenumount fix + improvements (#602)

* Remove misleading character escape.

Everything is in single quotes, so shell will escape it correctly
without backslashes. Fixes #440.

* Remove lsblk type restriction.

* Make it possible to cancel with ESC in dmenu.

Up to now if you pressed ESC to cancel the program would just continue
with incorrect data.
This commit is contained in:
mokulus authored and GitHub committed 2020-04-25 19:18:06 -04:00
1 parent 40faeb97ec
commit af4f814b0c
2 files changed
+18 -12

No files matched your search

+6 -4
View File
@@ -6,25 +6,27 @@
unmountusb() {
[ -z "$drives" ] && exit
chosen=$(echo "$drives" | dmenu -i -p "Unmount which drive?" | awk '{print $1}')
chosen="$(echo "$drives" | dmenu -i -p "Unmount which drive?")" || exit 1
chosen="$(echo "$chosen" | awk '{print $1}')"
[ -z "$chosen" ] && exit
sudo -A umount "$chosen" && notify-send "💻 USB unmounting" "$chosen unmounted."
}
unmountandroid() { \
chosen=$(awk '/simple-mtpfs/ {print $2}' /etc/mtab | dmenu -i -p "Unmount which device?")
chosen="$(awk '/simple-mtpfs/ {print $2}' /etc/mtab | dmenu -i -p "Unmount which device?")" || exit 1
[ -z "$chosen" ] && exit
sudo -A umount -l "$chosen" && notify-send "🤖 Android unmounting" "$chosen unmounted."
}
asktype() { \
case "$(printf "USB\\nAndroid" | dmenu -i -p "Unmount a USB drive or Android device?")" in
choice="$(printf "USB\\nAndroid" | dmenu -i -p "Unmount a USB drive or Android device?")" || exit 1
case "$choice" in
USB) unmountusb ;;
Android) unmountandroid ;;
esac
}
drives=$(lsblk -nrpo "name,type,size,mountpoint" | awk '$2=="part"&&$4!~/\/boot|\/home$|SWAP/&&length($4)>1{printf "%s (%s)\n",$4,$3}')
drives=$(lsblk -nrpo "name,type,size,mountpoint" | awk '$4!~/\/boot|\/home$|SWAP/&&length($4)>1{printf "%s (%s)\n",$4,$3}')
if ! grep simple-mtpfs /etc/mtab; then
[ -z "$drives" ] && echo "No drives to unmount." && exit