Browse Source

Prune existing mountpoints from dmenumount

master
Micah Halter 3 weeks ago
parent
commit
e01df5a460
2 changed files with 10 additions and 1 deletions
  1. 1
    0
      CHANGELOG.md
  2. 9
    1
      scripts/.config/Scripts/dmenumount

+ 1
- 0
CHANGELOG.md View File

@@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
26 26
 
27 27
 ### Changed
28 28
 
29
+- Prune folders from `dmenumount` that already have mounts in them
29 30
 - Removed `polybar` from installation, moved to `i3blocks`
30 31
 - Moved all applications to using the monospace definition in the fonts configuration
31 32
 - Changed some gpg settings

+ 9
- 1
scripts/.config/Scripts/dmenumount View File

@@ -6,14 +6,22 @@ pgrep -x dmenu && exit
6 6
 
7 7
 mountable=$(lsblk -lp -o NAME,FSTYPE,SIZE,TYPE,MOUNTPOINT|grep 'part\|lvm'|grep -v "\(part\|lvm\)[[:space:]]\+/\|t[[:space:]]\+\[SWAP\]\|crypto_LUKS"|awk '{print $1, "(" $3 ")"}')
8 8
 [[ "$mountable" = "" ]] && exit 1
9
+
9 10
 chosen=$(echo "$mountable"|$dmenu -i -p "Unmounted Drives:"|awk '{print $1}')
10 11
 [[ "$chosen" = "" ]] && exit 1
12
+
11 13
 sudo mount "$chosen" && exit 0
12
-dirs=$(find /mnt /media /mount /home -type d -maxdepth 5 2>/dev/null)
14
+
15
+already_mounted=$(lsblk -nrpo "name,type,mountpoint" | awk '$2=="part"&&$3!~/\/boot|\/home$|SWAP/&&length($3)>1{printf "-not \( -path *%s -prune \) \ \n",$3}')
16
+
17
+dirs=$(find /mnt /media /mount /home -type d -maxdepth 5 $already_mounted 2>/dev/null)
18
+
13 19
 mountpoint=$(echo "$dirs"|$dmenu -i -p "Mount Point:")
20
+
14 21
 [[ "$mountpoint" = "" ]] && exit 1
15 22
 if [[ ! -d "$mountpoint" ]]; then
16 23
   mkdiryn=$(echo -e "No\nYes" | $dmenu -i -p "Create?")
17 24
   [[ "$mkdiryn" = Yes ]] && sudo mkdir -p "$mountpoint"
18 25
 fi
26
+
19 27
 sudo mount $chosen $mountpoint && notify-send "$chosen mounted to $mountpoint"

Loading…
Cancel
Save