diff options
author | InigoGutierrez <inigogf.95@gmail.com> | 2019-03-10 16:48:16 +0100 |
---|---|---|
committer | InigoGutierrez <inigogf.95@gmail.com> | 2019-03-10 16:48:16 +0100 |
commit | 994f36babe776ebbd5bd60e90328ca3da771ec1d (patch) | |
tree | 6d4b2ecd08ec819f99ae376beaa12405871453ff | |
parent | d53a10c96b92fb6f759a78272950513c7f92f3ef (diff) | |
download | scripts-994f36babe776ebbd5bd60e90328ca3da771ec1d.tar.gz scripts-994f36babe776ebbd5bd60e90328ca3da771ec1d.zip |
Fixed mount scripts.
-rwxr-xr-x | dmenuMount.sh | 8 | ||||
-rwxr-xr-x | dmenuUmount.sh | 8 |
2 files changed, 9 insertions, 7 deletions
diff --git a/dmenuMount.sh b/dmenuMount.sh index a5fb0d7..e79d650 100755 --- a/dmenuMount.sh +++ b/dmenuMount.sh @@ -30,7 +30,7 @@ done <<< "$(lsblk -lp | grep "part $" )" lines=$(echo "$mountable" | wc -l) chosen=$(echo "$mountable" | dmenu -i -l $lines -p "Mount which drive?" | awk '{print $2}') [ "$chosen" == "" ] && exit 1 -sudo mount "$chosen" && pgrep -x dunst && notify-send "$chosen mounted" && exit 0 +sudo mount "$chosen" && pgrep -x dunst && notify-send "$chosen mounted." && exit 0 # Select mount point (reached if previous mount failed, e.g. device not in /etc/fstab) directories="" @@ -39,11 +39,11 @@ while read -r line do i=$((i+1)) directories="$directories$i. $line"$'\n' -done <<< "$(find /media ~/mounts -type d -maxdepth 3 -empty 2>/dev/null)" +done <<< "$(find /mnt $HOME/mounts -type d -maxdepth 3 -empty 2>/dev/null)" lines=$(echo "$directories" | wc -l) mountpoint=$(echo "$directories" | dmenu -i -l $lines -p "Type in mount point." | awk '{print $2}') [ "$mountpoint" == "" ] && exit 1 if [[ ! -d "$mountpoint" ]]; then - bash ~/scripts/prompt.sh "$mountpoint does not exist. Create it?" "mkdir -p $mountpoint" + prompt.sh "$mountpoint does not exist. Create it?" "sudo mkdir -p $mountpoint" fi -mount $chosen $mountpoint && pgrep -x dunst && notify-send "$chosen mounted to $mountpoint." +sudo mount $chosen $mountpoint && pgrep -x dunst && notify-send "$chosen mounted to $mountpoint." diff --git a/dmenuUmount.sh b/dmenuUmount.sh index 1669706..61af1c1 100755 --- a/dmenuUmount.sh +++ b/dmenuUmount.sh @@ -13,16 +13,18 @@ # Gives a dmenu prompt to umount mounted drives. # Shows mounted partitions; select one to unmount. -exclusionregex="\(/boot\|/home\|/\)$" +exclusionregex="\(/boot/efi\|/home\|/\)$" +list="$(lsblk -lp | grep "part /" | grep -v "$exclusionregex")" +[ "$list" == "" ] && notify-send -t 2000 "No devices found to unmount." && exit 0 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")" +done <<< "$list" [ "$drives" == "" ] && exit lines=$(echo "$drives" | wc -l) 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." +sudo umount $chosen && pgrep -x dunst && notify-send "$chosen unmounted." |