diff --git a/storage_menu.sh b/storage_menu.sh new file mode 100755 index 0000000..923b88f --- /dev/null +++ b/storage_menu.sh @@ -0,0 +1,43 @@ +#!/bin/sh +IFS=" +" + +any=0 +echo "" +for l in $(udiskie-info -a -o "{device_file} '{ui_id_label}' '{ui_id_uuid}' {is_filesystem} {is_luks} {is_mounted}"); do + IFS=" " + set -- $l + device=$1 + label=$2 + uuid=$3 + fs=$4 + luks=$5 + mounted=$6 + + # set label to UUID if none + # and strip single quotes, which made tokenization simpler + if [ "${label}" = "''" ]; then + label=${uuid} + fi + label=$(echo "${label}" | sed -e s/\'//g) + + # fs or luks should be true if we can mount it + if [ "${fs}" = "True" ] || [ "${luks}" = "True" ]; then + any=1 + if [ "${mounted}" = "True" ]; then + echo "" + echo "udiskie-umount ${device}" + echo "" + else + echo "" + echo "udiskie-mount ${device}" + echo "" + fi + fi +done + +if [ ${any} -eq 0 ]; then + echo "" +fi + +echo ""