Magellan Linux

Annotation of /trunk/include/xdg.sminc

Parent Directory Parent Directory | Revision Log Revision Log


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