Annotation of /trunk/include/xdg.sminc
Parent Directory | Revision Log
Revision 9702 -
(hide annotations)
(download)
Thu Jan 5 15:20:14 2012 UTC (12 years, 9 months ago) by niro
Original Path: branches/magellan-next/include/xdg.sminc
File size: 5585 byte(s)
Thu Jan 5 15:20:14 2012 UTC (12 years, 9 months ago) by niro
Original Path: branches/magellan-next/include/xdg.sminc
File size: 5585 byte(s)
-allow minstallxdg() to modify desktop files
1 | niro | 1934 | # $Id$ |
2 | niro | 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 | niro | 1934 | sminclude mtools |
32 | |||
33 | niro | 2 | # 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 | niro | 9702 | --source|-s) shift; source="$1" ;; |
68 | niro | 2 | 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 | niro | 9702 | local i |
127 | niro | 2 | local file |
128 | local destdir | ||
129 | local destfile | ||
130 | niro | 9702 | 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 | niro | 2 | |
143 | niro | 9702 | for i in $* |
144 | do | ||
145 | case $1 in | ||
146 | --srcdir|-s) shift; 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 | niro | 2 | |
160 | niro | 9702 | file="${prefix}$1" |
161 | |||
162 | if [[ -n "$2" ]] | ||
163 | niro | 2 | then |
164 | niro | 9702 | 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 | niro | 2 | then |
193 | niro | 9702 | # get all categories |
194 | for i in $(echo ${categories} | sed "s:,:\ :g") | ||
195 | do | ||
196 | cmdline+=" --add-category ${i}" | ||
197 | done | ||
198 | niro | 2 | fi |
199 | |||
200 | niro | 9702 | # get all mimetypes |
201 | if [[ ! -z ${mimetypes} ]] | ||
202 | niro | 2 | then |
203 | niro | 9702 | for i in $(echo ${mimetypes} | sed "s:,:\ :g") |
204 | do | ||
205 | cmdline+=" --add-mime-type ${i}" | ||
206 | done | ||
207 | niro | 2 | fi |
208 | |||
209 | niro | 9702 | desktop-file-install \ |
210 | --dir ${destdir} \ | ||
211 | --add-category X-Magellan-Application \ | ||
212 | ${cmdline} \ | ||
213 | ${file} \ | ||
214 | || die | ||
215 | niro | 2 | else |
216 | niro | 9702 | # install our xdg |
217 | minstallfile ${file} ${destdir}/${destfile} || die | ||
218 | niro | 2 | fi |
219 | } |