#!/bin/sh run-standalone.sh dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint string:"Welcome to Excalibur Script!" sleep 2 JAR=$1 if [ ! -f "${JAR}" ]; then run-standalone.sh dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint string:"JAR file does not exist!" && sleep 3 echo "Usage: excalibur JAR file"; exit 1 fi JAD="${JAR%.*}.jad" if [ -f "${JAD}" ]; then echo -n "${JAD} already exists, overwrite the file? (Y/N) " read midlet answer=$(echo "$midlet" | tr '[:upper:]' '[:lower:]') if [ "$answer" != "y" ] && [ "$answer" != "Y" ]; then echo "Not overwriting ${JAD} file!" else rm -f "${JAD}" fi fi if [ ! -f "${JAD}" ]; then unzip -aa -j -p ${JAR} "META-INF/MANIFEST.MF" | sed -e '/^[ \t]*$/d' > "${JAD}" echo "MIDlet-Jar-URL: ${JAR}" >> "${JAD}" echo "MIDlet-Info-URL: http://" >> "${JAD}" FILESIZE=$(stat "${JAR}") echo "MIDlet-Jar-Size: ${FILESIZE}" >> "${JAD}" echo "${JAD} file created!" # find png file MIDLET_ICON=`grep "MIDlet-Icon: " $JAD | sed "s/\MIDlet-Icon://g" | sed 's/\///g' | sed 's/^[ \t]*//'` # use the correct name of the icon file MIDLET_NAME=`grep "MIDlet-Name: " $JAD | sed /MIDlet-Name:/s/// | sed 's/^[a \t]*//' | sed 's/ .*//'` # extract the icon UNZIP_ICON=`unzip "$JAR" "$MIDLET_ICON" -d /usr/share/icons/hicolor/scalable/hildon/` # rename the icon using the midlet name RENAME_ICON=`mv "/usr/share/icons/hicolor/scalable/hildon/$MIDLET_ICON" "/usr/share/icons/hicolor/scalable/hildon/$MIDLET_NAME.png"` fi SH="${JAR%.*}.sh" if [ -f "${SH}" ]; then echo -n "${SH} Already exists, overwrite the file? (Y/N) " read midlet answer=$(echo "$midlet" | tr '[:upper:]' '[:lower:]') if [ "$answer" != "y" ] && [ "$answer" != "Y" ]; then echo "Not overwriting ${SH} file!" else rm -f "${SH}" fi fi if [ ! -f "${SH}" ]; then MAINCLASS=`cat $JAD | grep 'MIDlet-1:' | cut -d ',' -f 3` READLINKJAR=`readlink -f $JAR` echo '#!/bin/sh' > $SH echo '' >> $SH echo '/opt/phoneme/bin/cvm -Xmx12m -Dmicroedition.profiles=MIDP-2.1 -Dsun.midp.library.name=midp -Dsun.midp.home.path=/opt/phoneme/midp/midp_linux_fb_gcc -Dcom.sun.midp.mainClass.name=com.sun.midp.main.CdcMIDletSuiteLoader sun.misc.MIDPLauncher -suitepath' $READLINKJAR '-jadpath' $JAD -1 $MAINCLASS >> $SH chmod a+x $SH echo "${SH} file created!" READLINK=`readlink -f $SH` MIDLET_NAME=`grep "MIDlet-Name: " $JAD | sed /MIDlet-Name:/s/// | sed 's/^[a \t]*//' | sed 's/ .*//'` MIDLET_VERSION=`grep "MIDlet-Version: " $JAD | sed /MIDlet-Version:/s///` echo -e "[Desktop Entry] Encoding=UTF-8 Version=$MIDLET_VERSION Type=Application Name=$MIDLET_NAME Exec=.$READLINK Comment=`readlink -f $JAD` Comment=`readlink -f $JAR` X-Osso-Type=application/x-executable Terminal=true Icon=$MIDLET_NAME" | sudo tee /usr/share/applications/hildon/"$MIDLET_NAME".desktop sleep 6 echo "$MIDLET_NAME added as a desktop shortcut" sleep 4 fi echo "Does the midlet work fine? Run it and and come back here to say (Y/N)" read test ICONS_PATH=/usr/share/icons/hicolor/scalable/hildon/ DESKTOP_PATH=/usr/share/applications/hildon answer0=$(echo "$test" | tr '[:upper:]' '[:lower:]') if [ "$answer0" != "n" ] && [ "$answer0" != "N" ]; then run-standalone.sh dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint string:"Thanks for using Excalibur Script!" && sleep 3 exit 1; else echo "Write the Midlet Name here: " read input_name DESKTOP_FILE=`grep "$input_name" $DESKTOP_PATH/* | sed -e 's/[^:]*$//g' | sed -e 's/[:^]//g'` SH_FILE=`cat $DESKTOP_FILE | grep "Exec=." | sed /Exec=./s///` JAR_FILE=`cat $DESKTOP_FILE | grep ".jar" | sed /Comment=/s///` JAD_FILE=`cat $DESKTOP_FILE | grep ".jad" | sed /Comment=/s///` ICON_FILE=`cat $DESKTOP_FILE | grep "MIDlet-Name: " | sed /MIDlet-Name:/s/// | sed 's/^[ \t]*//' | sed 's/ //g'` echo "Do you want to remove $input_name? (Y/N)" read answer if [ "$answer" != "y" ] && [ "$answer" != "Y" ]; then echo "$input_name not removed!"; else echo "Removing all $input_name files . ." echo "Remoing $SH_FILE . ." sudo rm -rf $SH_FILE echo "Removed!" echo "Removing $JAR_FILE . ." sudo rm -rf $JAR_FILE echo "Removed!" echo "Removing $JAD_FILE . ." sudo rm -rf $JAD_FILE echo "Removed!" echo "Removing $ICON_FILE . ." sudo rm -rf $ICONS_PATH$ICON_FILE* echo "Removed!" echo "Removing $DESKTOP_FILE . ." sudo rm -rf $DESKTOP_FILE echo "Removed!" echo "All files Removed! Midlet is removed!" run-standalone.sh dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint string:"Thanks for using Excalibur Script!" && sleep 3 fi fi fi exec /usr/bin/gtk-update-icon-cache
#!/bin/sh -e
#!/bin/sh -e [ -d "$1" ] && touch "$1"