Magellan Linux

Contents of /trunk/include/xdg.sminc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 23284 - (show annotations) (download)
Fri Nov 7 08:59:17 2014 UTC (9 years, 6 months ago) by niro
File size: 5838 byte(s)
-use xdg-tools to update icon resources
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 INHERITS="${INHERITS} xdg"
34
35 # required for xdg-icon-resource in xdg.minc to update pixmaps
36 DEPEND=">= x11-apps/xdg-utils-1.1"
37
38 # desktop-file-utils are needed
39 SDEPEND="${SDEPEND}
40 >= dev-util/desktop-file-utils-0.1"
41
42 # installs a desktop icon
43 minstall_desktop_icon()
44 {
45 local i
46 local name
47 local file
48 local comment
49 local exec
50 local icon
51 local terminal
52 local notify
53 local categories
54 local vendor
55 local all_categories
56 local mimetypes
57 local all_mimetypes
58
59 for i in $*
60 do
61 case $1 in
62 --name|-n) shift; name="$1" ;;
63 --file|-f) shift; file="$1.desktop" ;;
64 --comment|-m) shift; comment="$1" ;;
65 --exec|-e) shift; exec="$1" ;;
66 --icon|-i) shift; icon="$1" ;;
67 --terminal|-t) terminal="true" ;;
68 --no-notify|-y) notify="false" ;;
69 --categories|-c) shift; categories="$1" ;;
70 --vendor|-v) shift; vendor="$1" ;;
71 --mimetypes|-x) shift; mimetypes="$1" ;;
72 --source|-s) shift; source="$1" ;;
73 esac
74 shift
75 done
76
77 # sanity checks; abort if not given
78 #[[ -z ${name} ]] && die "minstall_desktop_icon() \$name not given."
79
80 # some sane defaults
81 [[ -z ${name} ]] && name="${PNAME}"
82 [[ -z ${file} ]] && file="${name}.desktop"
83 [[ -z ${exec} ]] && exec="${name}"
84 [[ -z ${icon} ]] && icon="${name}.png"
85 [[ -z ${terminal} ]] && terminal="false"
86 [[ -z ${notify} ]] && notify="true"
87 [[ -z ${vendor} ]] && vendor="X-Magellan"
88
89 # get all categories
90 if [[ -n ${categories} ]]
91 then
92 for i in $(echo ${categories} | sed "s:,:\ :g")
93 do
94 all_categories="${all_categories} --add-category ${i}"
95 done
96 fi
97
98 # get all mimetypes
99 if [[ -n ${mimetypes} ]]
100 then
101 for i in $(echo ${mimetypes} | sed "s:,:\ :g")
102 do
103 all_mimetypes="${all_mimetypes} --add-mime-type ${i}"
104 done
105 fi
106
107 echo "[Desktop Entry]
108 Encoding=UTF-8
109 Name=${name}
110 Comment=${comment}
111 Exec=${exec}
112 Icon=${icon}
113 Terminal=${terminal}
114 StartupNotify=${notify}
115 Type=Application" > ${SRCDIR}/${file}
116 desktop-file-install \
117 --vendor ${vendor} \
118 --delete-original \
119 --dir ${BINDIR}/usr/share/applications \
120 --add-category X-Magellan-Application \
121 ${all_categories} \
122 ${all_mimetyes} \
123 ${SRCDIR}/${file} \
124 || die
125 }
126
127 # installs already created desktop icons to application dir
128 # minstallxdg {-s} srcname destname {/path/to}
129 minstallxdg()
130 {
131 local i
132 local file
133 local destdir
134 local destfile
135 local prefix
136 local modify="0"
137 local comment
138 local exec
139 local icon
140 local terminal
141 local notify
142 local categories
143 local vendor
144 local all_categories
145 local mimetypes
146 local cmdline
147 local name
148
149 for i in $*
150 do
151 case $1 in
152 --srcdir|-s) prefix="${SOURCEDIR}/${PNAME}/" ;;
153 --name|-n) shift; name="$1"; modify="1" ;;
154 --comment|-m) shift; comment="$1"; modify="1" ;;
155 --exec|-e) shift; exec="$1"; modify="1" ;;
156 --icon|-i) shift; icon="$1"; modify="1" ;;
157 --terminal|-t) terminal="true"; modify="1" ;;
158 --no-notify|-y) notify="false"; modify="1" ;;
159 --categories|-c) shift; categories="$1"; modify="1" ;;
160 --vendor|-v) shift; vendor="$1"; modify="1" ;;
161 --mimetypes|-x) shift; mimetypes="$1"; modify="1" ;;
162 --file|-f) shift; file="$1" ;;
163 --destination-file|-df) shift; destfile="$1" ;;
164 --destination-dir|-d) shift; destdir="$1" ;;
165 esac
166 shift
167 done
168
169 [[ ! -z ${prefix} ]] && file="${prefix}${file}"
170
171 [[ -z ${destfile} ]] && destfile="$(basename ${file})"
172 [[ -z ${destdir} ]] && destdir="/usr/share/applications"
173 [[ -z ${file} ]] && die "No xdg desktop file given"
174
175 # needed directory
176 minstalldir ${destdir} || die
177
178 if [[ ${modify} = 1 ]]
179 then
180 [[ ! -z ${name} ]] && cmdline+=" --set-name=\"${name}\""
181 [[ ! -z ${comment} ]] && cmdline+=" --set-comment=\"${comment}\""
182 [[ ! -z ${exec} ]] && cmdline+=" --set-key=Exec --set-value=\"${exec}\""
183 [[ ! -z ${icon} ]] && cmdline+=" --set-icon=\"${icon}\""
184 [[ ! -z ${terminal} ]] && cmdline+=" --set-key=Terminal --set-value=false"
185 [[ ! -z ${notify} ]] && cmdline+=" --set-key=StartupNotify --set-value=false"
186 [[ ! -z ${vendor} ]] && cmdline+=" --vendor \"${vendor}\""
187
188 if [[ ! -z ${categories} ]]
189 then
190 # get all categories
191 for i in $(echo ${categories} | sed "s:,:\ :g")
192 do
193 cmdline+=" --add-category ${i}"
194 done
195 fi
196
197 # get all mimetypes
198 if [[ ! -z ${mimetypes} ]]
199 then
200 for i in $(echo ${mimetypes} | sed "s:,:\ :g")
201 do
202 cmdline+=" --add-mime-type ${i}"
203 done
204 fi
205
206 eval desktop-file-install \
207 --dir ${BINDIR}/${destdir} \
208 --add-category X-Magellan-Application \
209 ${cmdline} \
210 ${file} \
211 || die
212 else
213 # install our xdg
214 minstallfile ${file} ${destdir}/${destfile} || die
215 fi
216 }