rice/usm
2019-08-28 17:40:59 -07:00

24 lines
537 B
Bash
Executable File

#!/bin/sh
mntpnt="/mnt"
# pick out the drive but not sda because thats the main drive
choice=`lsblk -lp | \
grep -e 'part $' -e "part /mnt/*"| \
awk '{print $1, $4}' | \
dmenu -i -p 'Drive to (un)mount'`
if [ -z "$choice" ]; then exit; fi
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
umount $dev
rm -d "$mntpnt/$name"
else
mkdir -p "$mntpnt/$name"
mount "$dev" "$mntpnt/$name"
fi