rice/usm

28 lines
693 B
Plaintext
Raw Normal View History

2019-07-04 20:31:12 +00:00
#!/bin/sh
# pick out the drive but not sda because thats the main drive
choice=`lsblk -lp | \
2019-07-05 21:17:10 +00:00
grep 'disk ' | \
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
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
if grep -qs "$dev" /proc/mounts;
then
# unmount the drive
2019-09-07 23:17:33 +00:00
umount "$HOME/.mounts/$name"
rm -d "$HOME/.mounts/$name"
2019-07-05 21:17:10 +00:00
# check if we still need the .mounts directory or nah
if [ "`ls ~/.mounts/`" ]
then
rm -d ~/.mounts/
fi
else
# Finally we can mount the thing
mkdir -p "~/.mounts/$name"
mount "$dev" "~/.mounts/$name"
fi