aboutsummaryrefslogtreecommitdiff
path: root/dmenuUmount.sh
diff options
context:
space:
mode:
Diffstat (limited to 'dmenuUmount.sh')
-rw-r--r--dmenuUmount.sh13
1 files changed, 10 insertions, 3 deletions
diff --git a/dmenuUmount.sh b/dmenuUmount.sh
index f50f4aa..ecc5160 100644
--- a/dmenuUmount.sh
+++ b/dmenuUmount.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-# _ _
+# _
# __| |_ __ ___ ___ _ __ _ _
# / _` | '_ ` _ \ / _ \ '_ \| | | |
# | (_| | | | | | | __/ | | | |_| |
@@ -14,10 +14,17 @@
# Shows mounted partitions; select one to unmount.
exclusionregex="\(/boot\|/home\|/\)$"
-drives=$(lsblk -lp | grep "part /" | grep -v "$exclusionregex" | awk '{print $1, "(" $4 ")", "on", $7}')
+drives=""
+i=0
+while read -r line
+do
+ i=$((i+1))
+ drives="$drives$i. $( echo "$line" | awk '{print $1, "(" $4 ")", "on", $7}' )"$'\n'
+done <<< "$(lsblk -lp | grep "part /" | grep -v "$exclusionregex" )"
+
[[ "$drives" = "" ]] && exit
lines=$(echo "$drives" | wc -l)
-chosen=$(echo "$drives" | dmenu -i -l $lines -p "Unmount which drive?" | awk '{print $1}')
+chosen=$(echo "$drives" | dmenu -i -l $lines -p "Unmount which drive?" | awk '{print $2}')
[[ "$chosen" = "" ]] && exit
umount $chosen && pgrep -x dunst && notify-send "$chosen unmounted."
#umount $chosen && notify-send "$chosen unmounted."