2022-07-04 21:36:33 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# A dmenu prompt to unmount drives.
|
|
|
|
# Provides you with mounted partitions, select one to unmount.
|
|
|
|
# Drives mounted at /, /boot and /home will not be options to unmount.
|
|
|
|
|
2023-02-07 17:19:53 +01:00
|
|
|
drives="$(
|
2024-01-02 19:09:46 +01:00
|
|
|
lsblk -nrpo "name,type,size,mountpoint,label" | awk -F':' '{gsub(/ /,":")}$4!~/\/boot|\/efi|\/home$|SWAP/&&length($4)>1{printf "%s (%s) %s\n",$4,$3,$5}'
|
|
|
|
awk '/simple-mtpfs/ { print "", $2; }' /etc/mtab
|
2023-02-07 17:19:53 +01:00
|
|
|
)"
|
2022-07-04 21:36:33 +02:00
|
|
|
|
2023-02-04 22:15:35 +01:00
|
|
|
chosen="$(echo "$drives" | dmenu -i -p "Unmount which drive?")" || exit 1
|
2022-07-04 21:36:33 +02:00
|
|
|
|
2023-04-12 11:37:10 +02:00
|
|
|
if case "$chosen" in
|
2024-01-02 19:09:46 +01:00
|
|
|
*)
|
|
|
|
chosen="${chosen#📱 }"
|
|
|
|
sudo -A umount -l "$chosen"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
chosen="${chosen% (*}"
|
|
|
|
sudo -A umount -l "$chosen"
|
|
|
|
;;
|
|
|
|
esac then
|
|
|
|
notify-send "禍 Drive unmounted." "$chosen successfully unmounted."
|
2023-04-12 11:37:10 +02:00
|
|
|
else
|
2024-01-02 19:09:46 +01:00
|
|
|
notify-send "禍 Drive failed to unmount." "Possibly a permissions or I/O issue."
|
2023-04-12 11:37:10 +02:00
|
|
|
fi
|
2022-07-04 21:36:33 +02:00
|
|
|
|
2023-02-07 17:19:53 +01:00
|
|
|
sudo -A umount "$chosen" && notify-send "禍 USB unmounting" "$chosen unmounted."
|
2022-07-04 21:36:33 +02:00
|
|
|
|
2023-02-07 17:19:53 +01:00
|
|
|
sudo -A umount -l "$chosen" && notify-send " Android unmounting" "$chosen unmounted."
|