1
0
Fork 0
dot/.local/bin/fuzzel_mount.sh

36 lines
727 B
Bash
Raw Normal View History

2023-08-12 01:23:53 +02:00
#!/usr/bin/sh
#
# fuzzel_mount.sh
#
# Mount devices. Requires fuzzel and udisksctl.
LSBLK_PART_TYPE="part"
LSBLK_LIST=$(lsblk -Ppo name,type,mountpoint)
while read -r line; do
while read -r keyval; do
eval "$keyval"
done <<- EOF
$line
EOF
expr "$NAME" : "/dev/sda." && continue
[ "$TYPE" = "$LSBLK_PART_TYPE" ] || continue
if [ -n "$MOUNTPOINT" ]; then
option_list=$(printf %s%s\\n "$option_list" "udisksctl unmount -b $NAME")
else
option_list=$(printf %s%s\\n "$option_list" "udisksctl mount -b $NAME")
fi
done <<- EOF
$LSBLK_LIST
EOF
selection=$(printf %s "$option_list" | fuzzel --dmenu --prompt "$ ")
if [ -n "$selection" ]; then
# TODO: notification and error reporting
exec $selection
fi