summaryrefslogtreecommitdiffstats
path: root/.local/bin/dmenuumount
diff options
context:
space:
mode:
authormokulus <36231852+mokulus@users.noreply.github.com>2020-04-26 01:18:06 +0200
committerGitHub <noreply@github.com>2020-04-25 19:18:06 -0400
commitaf4f814b0cb8326368d3ccaa9934ec9342f0728a (patch)
tree38587afa01ba9d2e55c6b6862037b7dc2b79fa76 /.local/bin/dmenuumount
parent40faeb97ec72892cbfe1160735c970cd2fde246f (diff)
downloadeibhear-af4f814b0cb8326368d3ccaa9934ec9342f0728a.tar.gz
eibhear-af4f814b0cb8326368d3ccaa9934ec9342f0728a.tar.zst
eibhear-af4f814b0cb8326368d3ccaa9934ec9342f0728a.zip
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.
Diffstat (limited to '.local/bin/dmenuumount')
-rwxr-xr-x.local/bin/dmenuumount10
1 files changed, 6 insertions, 4 deletions
diff --git a/.local/bin/dmenuumount b/.local/bin/dmenuumount
index da0f401..26612ef 100755
--- a/.local/bin/dmenuumount
+++ b/.local/bin/dmenuumount
@@ -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