#!/bin/bash

echo '<JWM>'
while read I; do
	PARTITION=$(awk '{print $2}' <<< "$I")
	DRIVE=$(echo $PARTITION | tr -d [0-9])
	SIZE=$(awk '{print $1}' <<< "$I")
	case $PARTITION in
	sd*)
		[ "$(grep "$DRIVE" /root/.usb-drive-log-probepart)" ] && MEDIA="usbdrv" || MEDIA="drive" 
		FILESYSTEM=$(guess_fstype /dev/$PARTITION)
		[ $FILESYSTEM = swap ] && continue
		INFO="`cat /sys/block/$DRIVE/device/model`"
		;;
	scd*|sr*)
		MEDIA="optical"
		FILESYSTEM="iso9660"
		INFO=""
		;;
	mmc*)
		MEDIA="card"
		FILESYSTEM=$(guess_fstype /dev/$PARTITION)
		INFO="MMC/SD: `cat /sys/block/$DRIVE/device/name`"
		;;
	*)
		continue
		;;
	esac
	echo "<Program label=\"${PARTITION}   ${FILESYSTEM}   ${INFO}\" icon=\"/usr/local/lib/X11/pixmaps/${MEDIA}48.png\">$HOME/.pup_event/drive_${PARTITION}/AppRun</Program>"
done <<< "$(grep '^ .*[0-9]$' /proc/partitions | tr -s ' ' | cut -f4-5 -d' ' | grep -vE ' loop| ram')"
echo '</JWM>'
