Magellan Linux

Annotation of /trunk/include/xdg.sminc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 23284 - (hide 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 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     DEPEND=">= x11-apps/xdg-utils-1.1"
37    
38 niro 2 # 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 niro 9702 --source|-s) shift; source="$1" ;;
73 niro 2 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 niro 9702 local i
132 niro 2 local file
133     local destdir
134     local destfile
135 niro 9702 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 niro 12533 local name
148 niro 2
149 niro 9702 for i in $*
150     do
151     case $1 in
152 niro 9715 --srcdir|-s) prefix="${SOURCEDIR}/${PNAME}/" ;;
153 niro 9702 --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 niro 9716 --file|-f) shift; file="$1" ;;
163     --destination-file|-df) shift; destfile="$1" ;;
164     --destination-dir|-d) shift; destdir="$1" ;;
165 niro 9702 esac
166     shift
167     done
168 niro 2
169 niro 9716 [[ ! -z ${prefix} ]] && file="${prefix}${file}"
170 niro 9702
171 niro 9716 [[ -z ${destfile} ]] && destfile="$(basename ${file})"
172     [[ -z ${destdir} ]] && destdir="/usr/share/applications"
173 niro 9702 [[ -z ${file} ]] && die "No xdg desktop file given"
174    
175     # needed directory
176     minstalldir ${destdir} || die
177    
178     if [[ ${modify} = 1 ]]
179     then
180 niro 12532 [[ ! -z ${name} ]] && cmdline+=" --set-name=\"${name}\""
181     [[ ! -z ${comment} ]] && cmdline+=" --set-comment=\"${comment}\""
182 niro 12531 [[ ! -z ${exec} ]] && cmdline+=" --set-key=Exec --set-value=\"${exec}\""
183 niro 12532 [[ ! -z ${icon} ]] && cmdline+=" --set-icon=\"${icon}\""
184 niro 9702 [[ ! -z ${terminal} ]] && cmdline+=" --set-key=Terminal --set-value=false"
185     [[ ! -z ${notify} ]] && cmdline+=" --set-key=StartupNotify --set-value=false"
186 niro 12532 [[ ! -z ${vendor} ]] && cmdline+=" --vendor \"${vendor}\""
187 niro 9702
188     if [[ ! -z ${categories} ]]
189 niro 2 then
190 niro 9702 # get all categories
191     for i in $(echo ${categories} | sed "s:,:\ :g")
192     do
193     cmdline+=" --add-category ${i}"
194     done
195 niro 2 fi
196    
197 niro 9702 # get all mimetypes
198     if [[ ! -z ${mimetypes} ]]
199 niro 2 then
200 niro 9702 for i in $(echo ${mimetypes} | sed "s:,:\ :g")
201     do
202     cmdline+=" --add-mime-type ${i}"
203     done
204 niro 2 fi
205    
206 niro 12531 eval desktop-file-install \
207 niro 12527 --dir ${BINDIR}/${destdir} \
208 niro 9702 --add-category X-Magellan-Application \
209     ${cmdline} \
210     ${file} \
211     || die
212 niro 2 else
213 niro 9702 # install our xdg
214     minstallfile ${file} ${destdir}/${destfile} || die
215 niro 2 fi
216     }