Contents of /branches/R11-unstable/include/xdg.sminc
Parent Directory | Revision Log
Revision 9715 -
(show annotations)
(download)
Thu Jan 5 21:29:18 2012 UTC (12 years, 9 months ago) by niro
Original Path: branches/magellan-next/include/xdg.sminc
File size: 5578 byte(s)
Thu Jan 5 21:29:18 2012 UTC (12 years, 9 months ago) by niro
Original Path: branches/magellan-next/include/xdg.sminc
File size: 5578 byte(s)
-fixed getops
1 | # $Id$ |
2 | # xdg-utils |
3 | |
4 | # for a complete list of known categories see: |
5 | # http://standards.freedesktop.org/menu-spec/menu-spec-1.0.html#category-registry |
6 | # |
7 | # AudioVideo Audio Video Development Education |
8 | # Game Graphics Network Office Settings System |
9 | # Utility Building Debugger IDE GUIDesigner |
10 | # Profiling RevisionControl Translation Calendar |
11 | # ContactManagement Database Dictionary Chart |
12 | # Email Finance FlowChart PDA ProjectManagement |
13 | # Presentation Spreadsheet WordProcessor 2DGraphics |
14 | # VectorGraphics RasterGraphics 3DGraphics Scanning |
15 | # OCR Photography Viewer DesktopSettings HardwareSettings |
16 | # PackageManager Dialup InstantMessaging IRCClient |
17 | # FileTransfer HamRadio News P2P RemoteAccess Telephony |
18 | # WebBrowser WebDevelopment Midi Mixer Sequencer Tuner |
19 | # TV AudioVideoEditing Player Recorder DiscBurning |
20 | # ActionGame AdventureGame ArcadeGame BoardGame |
21 | # BlocksGame CardGame KidsGame LogicGame RolePlaying |
22 | # Simulation SportsGame StrategyGame Art Construction |
23 | # Music Languages Science Astronomy Biology Chemistry |
24 | # Geology Math MedicalSoftware Physics Amusement |
25 | # Archiving Electronics Emulator Engineering |
26 | # FileManager TerminalEmulator Filesystem Monitor |
27 | # Security Accessibility Calculator Clock TextEditor |
28 | # Core KDE GNOME GTK Qt Motif Java ConsoleOnly Screensaver |
29 | # TrayIcon Applet Shell |
30 | |
31 | sminclude mtools |
32 | |
33 | # desktop-file-utils are needed |
34 | SDEPEND="${SDEPEND} |
35 | >= dev-util/desktop-file-utils-0.1" |
36 | |
37 | # installs a desktop icon |
38 | minstall_desktop_icon() |
39 | { |
40 | local i |
41 | local name |
42 | local file |
43 | local comment |
44 | local exec |
45 | local icon |
46 | local terminal |
47 | local notify |
48 | local categories |
49 | local vendor |
50 | local all_categories |
51 | local mimetypes |
52 | local all_mimetypes |
53 | |
54 | for i in $* |
55 | do |
56 | case $1 in |
57 | --name|-n) shift; name="$1" ;; |
58 | --file|-f) shift; file="$1.desktop" ;; |
59 | --comment|-m) shift; comment="$1" ;; |
60 | --exec|-e) shift; exec="$1" ;; |
61 | --icon|-i) shift; icon="$1" ;; |
62 | --terminal|-t) terminal="true" ;; |
63 | --no-notify|-y) notify="false" ;; |
64 | --categories|-c) shift; categories="$1" ;; |
65 | --vendor|-v) shift; vendor="$1" ;; |
66 | --mimetypes|-x) shift; mimetypes="$1" ;; |
67 | --source|-s) shift; source="$1" ;; |
68 | esac |
69 | shift |
70 | done |
71 | |
72 | # sanity checks; abort if not given |
73 | #[[ -z ${name} ]] && die "minstall_desktop_icon() \$name not given." |
74 | |
75 | # some sane defaults |
76 | [[ -z ${name} ]] && name="${PNAME}" |
77 | [[ -z ${file} ]] && file="${name}.desktop" |
78 | [[ -z ${exec} ]] && exec="${name}" |
79 | [[ -z ${icon} ]] && icon="${name}.png" |
80 | [[ -z ${terminal} ]] && terminal="false" |
81 | [[ -z ${notify} ]] && notify="true" |
82 | [[ -z ${vendor} ]] && vendor="X-Magellan" |
83 | |
84 | # get all categories |
85 | if [[ -n ${categories} ]] |
86 | then |
87 | for i in $(echo ${categories} | sed "s:,:\ :g") |
88 | do |
89 | all_categories="${all_categories} --add-category ${i}" |
90 | done |
91 | fi |
92 | |
93 | # get all mimetypes |
94 | if [[ -n ${mimetypes} ]] |
95 | then |
96 | for i in $(echo ${mimetypes} | sed "s:,:\ :g") |
97 | do |
98 | all_mimetypes="${all_mimetypes} --add-mime-type ${i}" |
99 | done |
100 | fi |
101 | |
102 | echo "[Desktop Entry] |
103 | Encoding=UTF-8 |
104 | Name=${name} |
105 | Comment=${comment} |
106 | Exec=${exec} |
107 | Icon=${icon} |
108 | Terminal=${terminal} |
109 | StartupNotify=${notify} |
110 | Type=Application" > ${SRCDIR}/${file} |
111 | desktop-file-install \ |
112 | --vendor ${vendor} \ |
113 | --delete-original \ |
114 | --dir ${BINDIR}/usr/share/applications \ |
115 | --add-category X-Magellan-Application \ |
116 | ${all_categories} \ |
117 | ${all_mimetyes} \ |
118 | ${SRCDIR}/${file} \ |
119 | || die |
120 | } |
121 | |
122 | # installs already created desktop icons to application dir |
123 | # minstallxdg {-s} srcname destname {/path/to} |
124 | minstallxdg() |
125 | { |
126 | local i |
127 | local file |
128 | local destdir |
129 | 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 | 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 | esac |
157 | shift |
158 | done |
159 | |
160 | file="${prefix}$1" |
161 | |
162 | if [[ -n "$2" ]] |
163 | then |
164 | destfile="$2" |
165 | else |
166 | destfile="$(basename ${file})" |
167 | fi |
168 | |
169 | if [[ -n "$3" ]] |
170 | then |
171 | destdir="$3" |
172 | else |
173 | destdir="/usr/share/applications" |
174 | fi |
175 | |
176 | [[ -z ${file} ]] && die "No xdg desktop file given" |
177 | |
178 | # needed directory |
179 | minstalldir ${destdir} || die |
180 | |
181 | if [[ ${modify} = 1 ]] |
182 | then |
183 | [[ ! -z ${name} ]] && cmdline+=" --set-name=\"${name}\"" |
184 | [[ ! -z ${comment} ]] && cmdline+=" --set-comment=\"${comment}\"" |
185 | [[ ! -z ${exec} ]] && cmdline+=" --set-key=Exec --set-value=\"${exec}\"" |
186 | [[ ! -z ${icon} ]] && cmdline+=" --set-icon=\"${icon}\"" |
187 | [[ ! -z ${terminal} ]] && cmdline+=" --set-key=Terminal --set-value=false" |
188 | [[ ! -z ${notify} ]] && cmdline+=" --set-key=StartupNotify --set-value=false" |
189 | [[ ! -z ${vendor} ]] && cmdline+=" --vendor \"${vendor}\"" |
190 | |
191 | if [[ ! -z ${categories} ]] |
192 | then |
193 | # get all categories |
194 | for i in $(echo ${categories} | sed "s:,:\ :g") |
195 | do |
196 | cmdline+=" --add-category ${i}" |
197 | done |
198 | fi |
199 | |
200 | # get all mimetypes |
201 | if [[ ! -z ${mimetypes} ]] |
202 | then |
203 | for i in $(echo ${mimetypes} | sed "s:,:\ :g") |
204 | do |
205 | cmdline+=" --add-mime-type ${i}" |
206 | done |
207 | fi |
208 | |
209 | desktop-file-install \ |
210 | --dir ${destdir} \ |
211 | --add-category X-Magellan-Application \ |
212 | ${cmdline} \ |
213 | ${file} \ |
214 | || die |
215 | else |
216 | # install our xdg |
217 | minstallfile ${file} ${destdir}/${destfile} || die |
218 | fi |
219 | } |