1 |
# $Header: /magellan-cvs/smage/include/xdg.sminc,v 1.9 2007-11-10 13:05:36 niro Exp $ |
# $Id$ |
2 |
# xdg-utils |
# xdg-utils |
3 |
|
|
4 |
# for a complete list of known categories see: |
# for a complete list of known categories see: |
28 |
# Core KDE GNOME GTK Qt Motif Java ConsoleOnly Screensaver |
# Core KDE GNOME GTK Qt Motif Java ConsoleOnly Screensaver |
29 |
# TrayIcon Applet Shell |
# TrayIcon Applet Shell |
30 |
|
|
31 |
|
sminclude mtools |
32 |
|
|
33 |
# desktop-file-utils are needed |
# desktop-file-utils are needed |
34 |
SDEPEND="${SDEPEND} |
SDEPEND="${SDEPEND} |
35 |
>= dev-util/desktop-file-utils-0.1" |
>= dev-util/desktop-file-utils-0.1" |
64 |
--categories|-c) shift; categories="$1" ;; |
--categories|-c) shift; categories="$1" ;; |
65 |
--vendor|-v) shift; vendor="$1" ;; |
--vendor|-v) shift; vendor="$1" ;; |
66 |
--mimetypes|-x) shift; mimetypes="$1" ;; |
--mimetypes|-x) shift; mimetypes="$1" ;; |
67 |
|
--source|-s) shift; source="$1" ;; |
68 |
esac |
esac |
69 |
shift |
shift |
70 |
done |
done |
123 |
# minstallxdg {-s} srcname destname {/path/to} |
# minstallxdg {-s} srcname destname {/path/to} |
124 |
minstallxdg() |
minstallxdg() |
125 |
{ |
{ |
126 |
|
local i |
127 |
local file |
local file |
128 |
local destdir |
local destdir |
129 |
local destfile |
local destfile |
130 |
|
local prefix |
131 |
|
local modify="0" |
132 |
|
local comment |
133 |
|
local exec |
134 |
|
local icon |
135 |
|
local terminal |
136 |
|
local notify |
137 |
|
local categories |
138 |
|
local vendor |
139 |
|
local all_categories |
140 |
|
local mimetypes |
141 |
|
local cmdline |
142 |
|
|
143 |
[[ -z "$1" ]] && die "No xdg desktop file given" |
for i in $* |
144 |
|
do |
145 |
|
case $1 in |
146 |
|
--srcdir|-s) prefix="${SOURCEDIR}/${PNAME}/" ;; |
147 |
|
--name|-n) shift; name="$1"; modify="1" ;; |
148 |
|
--comment|-m) shift; comment="$1"; modify="1" ;; |
149 |
|
--exec|-e) shift; exec="$1"; modify="1" ;; |
150 |
|
--icon|-i) shift; icon="$1"; modify="1" ;; |
151 |
|
--terminal|-t) terminal="true"; modify="1" ;; |
152 |
|
--no-notify|-y) notify="false"; modify="1" ;; |
153 |
|
--categories|-c) shift; categories="$1"; modify="1" ;; |
154 |
|
--vendor|-v) shift; vendor="$1"; modify="1" ;; |
155 |
|
--mimetypes|-x) shift; mimetypes="$1"; modify="1" ;; |
156 |
|
--file|-f) shift; file="$1" ;; |
157 |
|
--destination-file|-df) shift; destfile="$1" ;; |
158 |
|
--destination-dir|-d) shift; destdir="$1" ;; |
159 |
|
esac |
160 |
|
shift |
161 |
|
done |
162 |
|
|
163 |
# if no fullpath given use file from sourcedir |
[[ ! -z ${prefix} ]] && file="${prefix}${file}" |
|
if [[ $1 = -s ]] |
|
|
then |
|
|
file="${SOURCEDIR}/${PNAME}/$2" |
|
|
destfile="$3" |
|
|
|
|
|
else |
|
|
file="$1" |
|
|
fi |
|
164 |
|
|
165 |
if [[ $1 = -s ]] |
[[ -z ${destfile} ]] && destfile="$(basename ${file})" |
166 |
|
[[ -z ${destdir} ]] && destdir="/usr/share/applications" |
167 |
|
[[ -z ${file} ]] && die "No xdg desktop file given" |
168 |
|
|
169 |
|
# needed directory |
170 |
|
minstalldir ${destdir} || die |
171 |
|
|
172 |
|
if [[ ${modify} = 1 ]] |
173 |
then |
then |
174 |
file="${SOURCEDIR}/${PNAME}/$2" |
[[ ! -z ${name} ]] && cmdline+=" --set-name=\"${name}\"" |
175 |
if [[ -n "$3" ]] |
[[ ! -z ${comment} ]] && cmdline+=" --set-comment=\"${comment}\"" |
176 |
|
[[ ! -z ${exec} ]] && cmdline+=" --set-key=Exec --set-value=\"${exec}\"" |
177 |
|
[[ ! -z ${icon} ]] && cmdline+=" --set-icon=\"${icon}\"" |
178 |
|
[[ ! -z ${terminal} ]] && cmdline+=" --set-key=Terminal --set-value=false" |
179 |
|
[[ ! -z ${notify} ]] && cmdline+=" --set-key=StartupNotify --set-value=false" |
180 |
|
[[ ! -z ${vendor} ]] && cmdline+=" --vendor \"${vendor}\"" |
181 |
|
|
182 |
|
if [[ ! -z ${categories} ]] |
183 |
then |
then |
184 |
destfile="$3" |
# get all categories |
185 |
else |
for i in $(echo ${categories} | sed "s:,:\ :g") |
186 |
destfile="$(basename ${file})" |
do |
187 |
|
cmdline+=" --add-category ${i}" |
188 |
|
done |
189 |
fi |
fi |
190 |
|
|
191 |
if [[ -n "$4" ]] |
# get all mimetypes |
192 |
|
if [[ ! -z ${mimetypes} ]] |
193 |
then |
then |
194 |
destdir="$4" |
for i in $(echo ${mimetypes} | sed "s:,:\ :g") |
195 |
else |
do |
196 |
destdir="/usr/share/applications" |
cmdline+=" --add-mime-type ${i}" |
197 |
|
done |
198 |
fi |
fi |
199 |
|
|
200 |
|
desktop-file-install \ |
201 |
|
--dir ${destdir} \ |
202 |
|
--add-category X-Magellan-Application \ |
203 |
|
${cmdline} \ |
204 |
|
${file} \ |
205 |
|
|| die |
206 |
else |
else |
207 |
file="$1" |
# install our xdg |
208 |
if [[ -n "$2" ]] |
minstallfile ${file} ${destdir}/${destfile} || die |
|
then |
|
|
destfile="$2" |
|
|
else |
|
|
destfile="$(basename ${file})" |
|
|
fi |
|
|
|
|
|
if [[ -n "$3" ]] |
|
|
then |
|
|
destdir="$3" |
|
|
else |
|
|
destdir="/usr/share/applications" |
|
|
fi |
|
209 |
fi |
fi |
|
|
|
|
# needed directory |
|
|
install -d ${BINDIR}/${destdir} || die |
|
|
|
|
|
# install our xdg |
|
|
install -m 0644 -o root -g root ${file} ${BINDIR}/${destdir}/${destfile} || die |
|
210 |
} |
} |