#!/bin/bash # $Id$ usage() { echo echo "Usage: $0 --command [args] ..." echo echo " -n, --name [name] name of the desktop file" echo " -m, --comment [comment] comment to the programm" echo " -e, --exec [executable] /path/to/the/executable" echo " -i, --icon [icon] icon of the desktop file" echo " -c, --categorie [categorie] categories of the program" echo " -n, --notify enables notify" echo " -t, --terminal runs the program in a terminal" echo exit 1 } [ $# -lt 1 ] && usage # default values d_name="" d_comment="" d_exec="" d_icon="" d_categorie="" d_notify="true" d_terminal="true" # very basic getops for i in $* do case $1 in --name|-n) shift; d_name="$1" ;; --comment|-m) shift; d_comment="$1" ;; --exec|-e) shift; d_exec="$1" ;; --icon|-i) shift; d_icon="$1" ;; --categorie|c) shift; d_categorie="$1" ;; --notify|f) d_notify="true" ;; --terminal|-t) d_terminal="true" ;; esac shift done # sanity checks; abort if not given [ -z "${d_name}" ] && usage [ -z "${d_exec}" ] && usage [ -z "${d_categorie}" ] && usage [ -z "${d_notify}" ] && d_notify="false" [ -z "${d_terminal}" ] && d_terminal="false" [ ! -d ${MROOT}/usr/share/applications ] && \ install -d ${MROOT}/usr/share/applications echo "[Desktop Entry] Encoding=UTF-8 Name=${d_name} Comment=${d_comment} Exec=${d_exec} Icon=${d_icon} Terminal=${d_terminal} Type=Application Categories=${d_categorie} StartupNotify=${d_notify} " > ${MROOT}/usr/share/applications/${d_name}.desktop