34 lines
975 B
Bash
Executable File
34 lines
975 B
Bash
Executable File
#!/usr/bin/env sh
|
|
|
|
######################################################################
|
|
# @author : swytch (adapted form Luke Smith - lukesmith.xyz)
|
|
# @file : dmenuumount
|
|
# @license : GPLv3
|
|
# @created : Wednesday May 20, 2020 18:11:17 CEST
|
|
#
|
|
# @description : dmenu prompt to unmount drives
|
|
######################################################################
|
|
|
|
|
|
unmountusb() {
|
|
chosen=$(echo "$usbdrives" | dmenu -i -p "Unmount which drive?" | awk '{print $1}')
|
|
if [ -z "$chosen" ]; then
|
|
exit
|
|
else
|
|
if sudo -A umount "$chosen" ; then
|
|
notify-send " USB unmounting" "$chosen unmounted."
|
|
else
|
|
notify-send -u "critical" -t 3000 " USB ERROR" "Unmounting failed."
|
|
fi
|
|
fi
|
|
}
|
|
|
|
usbdrives=$(lsblk -nrpo "name,type,size,mountpoint" | awk \
|
|
'$2=="part"&&$4!~/\/boot|\/efi|\/home$|SWAP/&&length($4)>1{printf "%s (%s)\n",$4,$3}')
|
|
|
|
if [ -z "$usbdrives" ]; then
|
|
notify-send -u "critical" -t 3000 " USB ERROR" "No drive to unmount."
|
|
else
|
|
unmountusb
|
|
fi
|