cleanup: format dmenumount
and dmenuumount
This commit is contained in:
parent
cbc1e70790
commit
fbe75ff435
@ -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."
|
||||
}
|
||||
|
@ -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."
|
||||
|
Reference in New Issue
Block a user