2021-02-12 23:20:57 +01:00
|
|
|
#!/usr/bin/env sh
|
2020-05-06 03:20:19 +02:00
|
|
|
|
2020-05-20 18:34:34 +02:00
|
|
|
######################################################################
|
2021-02-14 19:07:45 +01:00
|
|
|
# @author : swytch (adapted form Luke Smith - lukesmith.xyz)
|
|
|
|
# @file : dmenuumount
|
2021-02-15 00:37:34 +01:00
|
|
|
# @license : GPLv3
|
2021-02-14 19:07:45 +01:00
|
|
|
# @created : Wednesday May 20, 2020 18:11:17 CEST
|
2020-05-20 18:34:34 +02:00
|
|
|
#
|
2021-02-14 19:07:45 +01:00
|
|
|
# @description : dmenu prompt to unmount drives
|
2020-05-20 18:34:34 +02:00
|
|
|
######################################################################
|
2020-05-06 03:20:19 +02:00
|
|
|
|
|
|
|
|
|
|
|
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
|
2020-09-29 00:38:54 +02:00
|
|
|
notify-send " USB unmounting" "$chosen unmounted."
|
2020-05-06 03:20:19 +02:00
|
|
|
else
|
2020-09-29 00:38:54 +02:00
|
|
|
notify-send -u "critical" -t 3000 " USB ERROR" "Unmounting failed."
|
2020-05-06 03:20:19 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-09-03 21:00:08 +02:00
|
|
|
usbdrives=$(lsblk -nrpo "name,type,size,mountpoint" | awk \
|
2021-07-12 17:20:29 +02:00
|
|
|
'$2=="part"&&$4!~/\/boot|\/efi|\/home$|SWAP/&&length($4)>1{printf "%s (%s)\n",$4,$3}')
|
2020-05-06 03:20:19 +02:00
|
|
|
|
|
|
|
if [ -z "$usbdrives" ]; then
|
2020-09-06 21:49:21 +02:00
|
|
|
notify-send -u "critical" -t 3000 " USB ERROR" "No drive to unmount."
|
2020-05-06 03:20:19 +02:00
|
|
|
else
|
|
|
|
unmountusb
|
|
|
|
fi
|