aboutsummaryrefslogtreecommitdiff
path: root/dmenuUmount.sh
diff options
context:
space:
mode:
authorInigoGutierrez <inigogf.95@gmail.com>2018-11-25 02:22:00 +0100
committerInigoGutierrez <inigogf.95@gmail.com>2018-11-25 02:22:00 +0100
commit02500565fa852dba828e9de91f34559cc0e41b1c (patch)
tree9a138c0c04b8a2d16b3120248cc598455bcbc937 /dmenuUmount.sh
parent9d7e66bff998ddf3bb8f1713ddbaf7a26d1b1411 (diff)
downloadscripts-02500565fa852dba828e9de91f34559cc0e41b1c.tar.gz
scripts-02500565fa852dba828e9de91f34559cc0e41b1c.zip
Mount scripts now use a dmenu numbered list
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."