#!/bin/bash
## RPJ 5.6.2023
## RJP 10.6.2023 typo corrected
# RJP 10.6.2023
# RJO 19.6.2026 Mine and generic name entries removed and new section entries
#
yad yad --width=500 --text-align=center --center --title=$"Desktop file builder" --text="Would you like to make custom desktop file?" --title="Make custom desktop file" --text="Would you like to make custom desktop file?" --title="Make custom desktop file"
if [ $? = 0 ];
then
NAME=`yad --center --width=500 --height=100 --text-align=center --button=OK:0 --text="SET PROGRAM NAME" --title=$"SET PROGRAM NAME HERE" --entry --entry-label=HERE --entry-text=""`
PROG=`cd /usr && yad --title=$"CHOOSE PROGRAM " --button=OK:0 --file --width=1000`
ICON=`cd /usr/share/icons && yad --title=$"CHOOSE ICON" --button=OK:0 --file --width=1000`
COMMENT=`yad --center --width=500 --height=100 --text-align=center --title=$"SET PROGRAM COMMENT HERE " --button=OK:0 --text="SET PROGRAM COMMENT" --entry --entry-label=HERE --entry-text=""`
CATE=`yad --center --width=500 --height=100 --text-align=center --title=$"SET PROGRAM CATEGORIES HERE " --button=OK:0 --text="SET PROGRAM CATEGORIES" --entry --entry-label=HERE --entry-text=""`
## optional MIME=`yad --center --width=500 --height=100 --text-align=center --title=$"SET PROGRAM MIMETYPE HERE " --button=OK:0 --text="SET PROGRAM MIMETYPE" --entry --entry-label=HERE --entry-text=""`
## optional GEN=`yad --center --width=500 --height=100 --text-align=center --title=$"SET PROGRAM GENERIC NAME HERE " --button=OK:0 --text="SET PROGRAM GENERIC NAME" --entry --entry-label=HERE --entry-text=""`
KW=`yad --center --width=500 --height=100 --text-align=center --title=$"SET PROGRAM KEYWORDS HERE " --button=OK:0 --text="SET PROGRAM KEYWORDS" --entry --entry-label=HERE --entry-text=""`
##
if [ $? = 0 ];
then
{
echo '#!/usr/bin/env xdg-open'
echo '[Desktop Entry]'
echo 'Version=1.0'
echo 'Type=Application'
echo 'Terminal=false'
echo "Icon=$ICON"
echo "Name=$NAME"
echo "TryExec=$PROG"
echo "Exec=$PROG"
echo "Comment=$COMMENT"
echo "Categories=$CATE;"
## optitional echo "MimeType=$MIME;"
## optitional echo "GenericName=$GEN;"
echo "Keywords=$KW;"
} > $HOME/$NAME.desktop
yad --center --width=500 --height=30 --button=OK:0 --text-align=center --title=$"New desktop file is made" --text="New desktop file is made"
else 
exit 1
fi
fi
