#!/bin/bash


OPENFILE=`kdialog --icon /usr/share/pixmaps/aiso2.png --caption "Select Image to Generate CUE" --getopenfilename $HOME/ "*.img *.bin"`
if test -z "$OPENFILE"
then 
exit
else
echo continua
fi

lol=`dirname "$OPENFILE"`

if test ! -w "$lol"
then
kdialog --caption "AcetoneISO2" --error "The Image you selected is located on a non-writable folder\nPlease be sure to have write permissions"
exit
else
echo continua
fi

kdialog --msgbox "CUE file has been created.\nFind it in the folder of the Image You choosed"

BASE=`echo "$OPENFILE" | sed 's/\.[^.]*$//'` 

var=`basename "$OPENFILE"`

cat << EOF > "${BASE}.cue"
FILE "$var" BINARY
  TRACK 01 MODE1/2352
    INDEX 01 00:00:00
EOF
