Magellan Linux

Annotation of /trunk/include/xdg.sminc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 9716 - (hide annotations) (download)
Thu Jan 5 21:42:46 2012 UTC (12 years, 4 months ago) by niro
Original Path: branches/magellan-next/include/xdg.sminc
File size: 5684 byte(s)
serveral fixes
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 niro 9715 --srcdir|-s) prefix="${SOURCEDIR}/${PNAME}/" ;;
147 niro 9702 --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 niro 9716 --file|-f) shift; file="$1" ;;
157     --destination-file|-df) shift; destfile="$1" ;;
158     --destination-dir|-d) shift; destdir="$1" ;;
159 niro 9702 esac
160     shift
161     done
162 niro 2
163 niro 9716 [[ ! -z ${prefix} ]] && file="${prefix}${file}"
164 niro 9702
165 niro 9716 [[ -z ${destfile} ]] && destfile="$(basename ${file})"
166     [[ -z ${destdir} ]] && destdir="/usr/share/applications"
167 niro 9702 [[ -z ${file} ]] && die "No xdg desktop file given"
168    
169     # needed directory
170     minstalldir ${destdir} || die
171    
172     if [[ ${modify} = 1 ]]
173     then
174     [[ ! -z ${name} ]] && cmdline+=" --set-name=\"${name}\""
175     [[ ! -z ${comment} ]] && cmdline+=" --set-comment=\"${comment}\""
176     [[ ! -z ${exec} ]] && cmdline+=" --set-key=Exec --set-value=\"${exec}\""
177     [[ ! -z ${icon} ]] && cmdline+=" --set-icon=\"${icon}\""
178     [[ ! -z ${terminal} ]] && cmdline+=" --set-key=Terminal --set-value=false"
179     [[ ! -z ${notify} ]] && cmdline+=" --set-key=StartupNotify --set-value=false"
180     [[ ! -z ${vendor} ]] && cmdline+=" --vendor \"${vendor}\""
181    
182     if [[ ! -z ${categories} ]]
183 niro 2 then
184 niro 9702 # get all categories
185     for i in $(echo ${categories} | sed "s:,:\ :g")
186     do
187     cmdline+=" --add-category ${i}"
188     done
189 niro 2 fi
190    
191 niro 9702 # get all mimetypes
192     if [[ ! -z ${mimetypes} ]]
193 niro 2 then
194 niro 9702 for i in $(echo ${mimetypes} | sed "s:,:\ :g")
195     do
196     cmdline+=" --add-mime-type ${i}"
197     done
198 niro 2 fi
199    
200 niro 9702 desktop-file-install \
201     --dir ${destdir} \
202     --add-category X-Magellan-Application \
203     ${cmdline} \
204     ${file} \
205     || die
206 niro 2 else
207 niro 9702 # install our xdg
208     minstallfile ${file} ${destdir}/${destfile} || die
209 niro 2 fi
210     }