1 |
#!/bin/bash |
#!/bin/bash |
2 |
|
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/create_desktop_app.sh,v 1.7 2005-09-09 16:34:35 niro Exp $ |
3 |
|
|
4 |
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/create_desktop_app.sh,v 1.6 2005-06-01 15:47:47 niro Exp $ |
usage() |
5 |
|
{ |
6 |
if [ $# -lt 1 ] |
echo |
7 |
then |
echo "Usage: $0 --command [args] ..." |
8 |
echo "Usage: $0 [Name] [Comment] [Executable] [Icon] [Categorie] [Notify] [Terminal]" |
echo |
9 |
|
echo " -n, --name [name] name of the desktop file" |
10 |
|
echo " -m, --comment [comment] comment to the programm" |
11 |
|
echo " -e, --exec [executable] /path/to/the/executable" |
12 |
|
echo " -i, --icon [icon] icon of the desktop file" |
13 |
|
echo " -c, --categorie [categorie] categories of the program" |
14 |
|
echo " -n, --notify enables notify" |
15 |
|
echo " -t, --terminal runs the program in a terminal" |
16 |
|
echo |
17 |
exit 1 |
exit 1 |
18 |
fi |
} |
19 |
|
|
20 |
|
[ $# -lt 1 ] && usage |
21 |
|
|
22 |
|
|
23 |
|
# default values |
24 |
|
d_name="" |
25 |
|
d_comment="" |
26 |
|
d_exec="" |
27 |
|
d_icon="" |
28 |
|
d_categorie="" |
29 |
|
d_notify="true" |
30 |
|
d_terminal="true" |
31 |
|
|
32 |
|
# very basic getops |
33 |
|
for i in $* |
34 |
|
do |
35 |
|
case $1 in |
36 |
|
--name|-n) shift; d_name="$1" ;; |
37 |
|
--comment|-m) shift; d_comment="$1" ;; |
38 |
|
--exec|-e) shift; d_exec="$1" ;; |
39 |
|
--icon|-i) shift; d_icon="$1" ;; |
40 |
|
--categorie|c) shift; d_categorie="$1" ;; |
41 |
|
--notify|f) d_notify="true" ;; |
42 |
|
--terminal|-t) d_terminal="true" ;; |
43 |
|
esac |
44 |
|
shift |
45 |
|
done |
46 |
|
|
47 |
|
# sanity checks; abort if not given |
48 |
|
[ -z "${d_name}" ] && usage |
49 |
|
[ -z "${d_exec}" ] && usage |
50 |
|
[ -z "${d_categorie}" ] && usage |
51 |
|
[ -z "${d_notify}" ] && d_notify="false" |
52 |
|
[ -z "${d_terminal}" ] && d_terminal="false" |
53 |
|
|
54 |
d_name=$1 |
[ ! -d ${MROOT}/usr/share/applications ] && \ |
55 |
d_comment=$2 |
install -d ${MROOT}/usr/share/applications |
|
d_exec=$3 |
|
|
d_icon=$4 |
|
|
d_categorie=$5 |
|
|
d_notify=$6 |
|
|
d_terminal=$7 |
|
|
|
|
|
if [ -d /usr/share/applications ] |
|
|
then |
|
|
mkdir -p /usr/share/applications |
|
|
fi |
|
56 |
|
|
57 |
echo "[Desktop Entry] |
echo "[Desktop Entry] |
58 |
Encoding=UTF-8 |
Encoding=UTF-8 |
64 |
Type=Application |
Type=Application |
65 |
Categories=${d_categorie} |
Categories=${d_categorie} |
66 |
StartupNotify=${d_notify} |
StartupNotify=${d_notify} |
67 |
" > /usr/share/applications/${d_name}.desktop |
" > ${MROOT}/usr/share/applications/${d_name}.desktop |