cleanup: format `dmenumount` and `dmenuumount`

This commit is contained in:
David 2020-09-03 21:00:08 +02:00
parent cbc1e70790
commit fbe75ff435
2 changed files with 7 additions and 4 deletions

View File

@ -22,12 +22,14 @@ getmount() { \
mountusb() { \
chosen="$(echo "$usbdrives" | dmenu -i -p "Mount which drive?" | awk '{print $1}')"
alreadymounted=$(lsblk -nrpo "name,type,mountpoint" | awk '$2=="part"&&$3!~/\/boot|\/home$|SWAP/&&length($3)>1{printf "-not \\( -path *%s -prune \\) \\ \n",$3}')
getmount "/mnt /media /mount /home -maxdepth 5 -type d $alreadymounted"
alreadymounted=$(lsblk -nrpo "name,type,mountpoint" \
| awk '$2=="part"&&$3!~/\/efi|\/home$|SWAP/&&length($3)>1\{printf "-not \\( -path *%s -prune \\) \\ \n",$3}')
getmount "/mnt /media /mount /home -maxdepth 2 -type d $alreadymounted"
partitiontype="$(lsblk -no "fstype" "$chosen")"
case "$partitiontype" in
"vfat") sudo -A mount -t vfat "$chosen" "$mp" -o rw,umask=0000;;
*) sudo -A mount "$chosen" "$mp"; user="$(whoami)"; ug="$(groups | awk '{print $1}')"; sudo -A chown "$user":"$ug" "$mp";;
*) sudo -A mount "$chosen" "$mp"; user="$(whoami)";
ug="$(groups | awk '{print $1}')"; sudo -A chown "$user":"$ug" "$mp";;
esac
notify-send "禍 USB mounting" "$chosen mounted to $mp."
}

View File

@ -23,7 +23,8 @@ else
fi
}
usbdrives=$(lsblk -nrpo "name,type,size,mountpoint" | awk '$2=="part"&&$4!~/\/boot|\/home$|SWAP/&&length($4)>1{printf "%s (%s)\n",$4,$3}')
usbdrives=$(lsblk -nrpo "name,type,size,mountpoint" | awk \
'$2=="part"&&$4!~/\/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."