rice/usm

25 lines
559 B
Plaintext
Raw Normal View History

2019-07-04 20:31:12 +00:00
#!/bin/sh
mntpnt="/mnt"
2019-07-04 20:31:12 +00:00
# pick out the drive but not sda because thats the main drive
choice=`lsblk -lp | \
grep -e 'part $' -e "part /mnt/*"| \
2019-07-05 21:17:10 +00:00
awk '{print $1, $4}' | \
dmenu -i -p 'Drive to (un)mount'`
if [ -z "$choice" ]; then exit; fi
2019-07-04 20:31:12 +00:00
dev=`echo $choice | awk '{print $1}'`
2019-07-05 21:17:10 +00:00
name="`basename $dev`"
if [ -z "$dev" ]; then exit; fi
# Check if it's already mounted / something was even picked
2019-07-05 21:17:10 +00:00
if grep -qs "$dev" /proc/mounts;
then
# unmount the drive
umount $dev
rm -d "$mntpnt/$name"
2019-07-05 21:17:10 +00:00
else
mkdir -p "$mntpnt/$name"
mount "$dev" "$mntpnt/$name"
2019-07-05 21:17:10 +00:00
fi