storage_menu.sh (raw)
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 |
#!/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>" |