#!/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 "" 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 "$?"