From 2e206acca7d4fe2071f21e529702627208599510 Mon Sep 17 00:00:00 2001 From: shockrahwow Date: Wed, 28 Aug 2019 17:34:42 -0700 Subject: [PATCH] fixed usb mounting script but it still requires root perms --- usm | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/usm b/usm index 8066f69..4199eb3 100755 --- a/usm +++ b/usm @@ -1,27 +1,24 @@ #!/bin/sh +mntpnt="/mnt" + # pick out the drive but not sda because thats the main drive choice=`lsblk -lp | \ - grep 'disk ' | \ + grep -e 'part $' -e "part /mnt/*"| \ awk '{print $1, $4}' | \ dmenu -i -p 'Drive to (un)mount'` if [ -z "$choice" ]; then exit; fi -# Check if it's already mounted / something was even picked dev=`echo $choice | awk '{print $1}'` name="`basename $dev`" if [ -z "$dev" ]; then exit; fi + +# Check if it's already mounted / something was even picked if grep -qs "$dev" /proc/mounts; then # unmount the drive - umount "~/.mounts/$name" - rm -d "~/.mounts/$name" - # check if we still need the .mounts directory or nah - if [ "`ls ~/.mounts/`" ] - then - rm -d ~/.mounts/ - fi + umount $dev + rm -d "$mntpnt/$name" else - # Finally we can mount the thing - mkdir -p "~/.mounts/$name" - mount "$dev" "~/.mounts/$name" + mkdir -p "$mntpnt/$name" + mount "$dev" "$mntpnt/$name" fi