blob: b60976512d0f1a9e9602bfe68eac6570951dab17 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#!/bin/sh
mkdir $HOME/media 2>/dev/null
CHOICE=$(lsblk --json -o LABEL,PATH,SIZE,FSTYPE,TYPE,PARTLABEL,MOUNTPOINT |
jq -r '.blockdevices[] | select(
.type=="part" and
.mountpoint==null and
.fstype!=null and
.fstype!="crypto_LUKS" and
.fstype!="swap" and
.label!="WIN10_C" and
.label!="win10_c" and
.label!="DSRESTORE" and
.label!="partestroot" and
.label!="debian-root" and
.label!="partestboot" and
.partlabel!="boot" and
.partlabel!="EFI" and
.partlabel!="arch-root-amd64" and
.partlabel!="EFI system partition" and
.partlabel!="McAfeeEpeReserved" and
.partlabel!="Microsoft reserved partition" and
1==1) | [.path, .size, .label, if (.partlabel|length)>0
then .partlabel
else "<no-partlabel>"
end, .fstype] | @tsv' |
$PICKER -p 'Mount partition: ') || {
printf "No selection\n" && notify-send "No selection" && exit 1
}
printf "CHOICE: %s\n" "$CHOICE"
DEV=${CHOICE%%[[:blank:]]*}
printf "DEV: %s\n" "$DEV"
LABEL=$(lsblk -n -oLABEL $DEV)
[ -z "$LABEL" ] && LABEL=$(lsblk -n -oUUID $DEV)
FSTYPE=$(lsblk -n -oFSTYPE $DEV)
case $FSTYPE in
'vfat'|'exfat'|'ntfs')
mountargs="uid=$(id -u)"
;;
*)
;;
esac
MDIR=$HOME/media/$LABEL
mkdir $MDIR 2>/dev/null
doas /usr/bin/mount -o $mountargs $DEV $MDIR
notify-send -t 4000 "$?"
|