Magellan Linux

Annotation of /trunk/include/xdg.sminc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 12533 - (hide annotations) (download)
Wed Jun 6 20:49:47 2012 UTC (12 years, 4 months ago) by niro
File size: 5711 byte(s)
-define name as local variable to prevent a global var re-define
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 12533 local name
143 niro 2
144 niro 9702 for i in $*
145     do
146     case $1 in
147 niro 9715 --srcdir|-s) prefix="${SOURCEDIR}/${PNAME}/" ;;
148 niro 9702 --name|-n) shift; name="$1"; modify="1" ;;
149     --comment|-m) shift; comment="$1"; modify="1" ;;
150     --exec|-e) shift; exec="$1"; modify="1" ;;
151     --icon|-i) shift; icon="$1"; modify="1" ;;
152     --terminal|-t) terminal="true"; modify="1" ;;
153     --no-notify|-y) notify="false"; modify="1" ;;
154     --categories|-c) shift; categories="$1"; modify="1" ;;
155     --vendor|-v) shift; vendor="$1"; modify="1" ;;
156     --mimetypes|-x) shift; mimetypes="$1"; modify="1" ;;
157 niro 9716 --file|-f) shift; file="$1" ;;
158     --destination-file|-df) shift; destfile="$1" ;;
159     --destination-dir|-d) shift; destdir="$1" ;;
160 niro 9702 esac
161     shift
162     done
163 niro 2
164 niro 9716 [[ ! -z ${prefix} ]] && file="${prefix}${file}"
165 niro 9702
166 niro 9716 [[ -z ${destfile} ]] && destfile="$(basename ${file})"
167     [[ -z ${destdir} ]] && destdir="/usr/share/applications"
168 niro 9702 [[ -z ${file} ]] && die "No xdg desktop file given"
169    
170     # needed directory
171     minstalldir ${destdir} || die
172    
173     if [[ ${modify} = 1 ]]
174     then
175 niro 12532 [[ ! -z ${name} ]] && cmdline+=" --set-name=\"${name}\""
176     [[ ! -z ${comment} ]] && cmdline+=" --set-comment=\"${comment}\""
177 niro 12531 [[ ! -z ${exec} ]] && cmdline+=" --set-key=Exec --set-value=\"${exec}\""
178 niro 12532 [[ ! -z ${icon} ]] && cmdline+=" --set-icon=\"${icon}\""
179 niro 9702 [[ ! -z ${terminal} ]] && cmdline+=" --set-key=Terminal --set-value=false"
180     [[ ! -z ${notify} ]] && cmdline+=" --set-key=StartupNotify --set-value=false"
181 niro 12532 [[ ! -z ${vendor} ]] && cmdline+=" --vendor \"${vendor}\""
182 niro 9702
183     if [[ ! -z ${categories} ]]
184 niro 2 then
185 niro 9702 # get all categories
186     for i in $(echo ${categories} | sed "s:,:\ :g")
187     do
188     cmdline+=" --add-category ${i}"
189     done
190 niro 2 fi
191    
192 niro 9702 # get all mimetypes
193     if [[ ! -z ${mimetypes} ]]
194 niro 2 then
195 niro 9702 for i in $(echo ${mimetypes} | sed "s:,:\ :g")
196     do
197     cmdline+=" --add-mime-type ${i}"
198     done
199 niro 2 fi
200    
201 niro 12531 eval desktop-file-install \
202 niro 12527 --dir ${BINDIR}/${destdir} \
203 niro 9702 --add-category X-Magellan-Application \
204     ${cmdline} \
205     ${file} \
206     || die
207 niro 2 else
208 niro 9702 # install our xdg
209     minstallfile ${file} ${destdir}/${destfile} || die
210 niro 2 fi
211     }