#!/bin/bash

# How to make desktop launcher icons for Utsusemi Apps:
#   1. Add folder path including this file to PATH
#   2. Type "CreateGnomeDesktopApps" to launch this to make desktop icons
#   3. Right click on icons shows menu, then choose "Allow Launching"

_DIR_="$(cd "$(dirname "${BASH_SOURCE:-$0}")"; pwd)"
source "${_DIR_}/_loadenv"

APP_NAMES=("D4mat" "D4mat2" "Sequencer" "M2Plot" "EnvironSetting" "MPlot")
COMMENTS=("D4Mat Slicer" "D4Mat2 Slicer" "Commands Sequence Editor" "uGao M2Plot+" "Settings" "MPlot")

i=0
for appname in "${APP_NAMES[@]}"
do
    appfile="${_DIR_}/_apps/${appname}.desktop"
    echo "File="${appfile}
    echo "[Desktop Entry]" > ${appfile}
    echo "Name="${appname}  >> ${appfile}
    echo "Comment="${COMMENTS[i]} >> ${appfile}
    echo "Exec="${UTSUSEMI_BASE_DIR}"/bin/_apps/"${appname} >> ${appfile}
    echo "Icon="${UTSUSEMI_BASE_DIR}"/bin/_apps/icons/gnome_icon_"${appname}".png" >> ${appfile}
    #echo "Icon=" >> ${appfile}
    echo "Terminal=false" >> ${appfile}
    echo "Type=Application" >> ${appfile}
    chmod a+x ${appfile}
    cp ${appfile} ~/Desktop/
    #gio set ~/Desktop/${appname}.desktop metadata::trusted yes
    let i++
done
