zenUtils/storage_menu.sh

43 lines
1 KiB
Bash
Executable file

#!/bin/sh
IFS="
"
any=0
echo "<openbox_pipe_menu>"
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 "<item label=\"${device}: ${label} ⏏\">"
echo "<action name=\"Execute\"><execute>udiskie-umount ${device}</execute></action>"
echo "</item>"
else
echo "<item label=\"${device}: ${label}\">"
echo "<action name=\"Execute\"><execute>udiskie-mount ${device}</execute></action>"
echo "</item>"
fi
fi
done
if [ ${any} -eq 0 ]; then
echo "<separator label=\"none\"/>"
fi
echo "</openbox_pipe_menu>"