Contents of /branches/R11-stable/include/xdg.sminc
Parent Directory | Revision Log
Revision 2 -
(show annotations)
(download)
Fri Oct 10 13:29:42 2008 UTC (15 years, 11 months ago) by niro
Original Path: trunk/core/include/xdg.sminc
File size: 4303 byte(s)
Fri Oct 10 13:29:42 2008 UTC (15 years, 11 months ago) by niro
Original Path: trunk/core/include/xdg.sminc
File size: 4303 byte(s)
import repo
1 | # $Header: /magellan-cvs/smage/include/xdg.sminc,v 1.9 2007-11-10 13:05:36 niro Exp $ |
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 | # desktop-file-utils are needed |
32 | SDEPEND="${SDEPEND} |
33 | >= dev-util/desktop-file-utils-0.1" |
34 | |
35 | # installs a desktop icon |
36 | minstall_desktop_icon() |
37 | { |
38 | local i |
39 | local name |
40 | local file |
41 | local comment |
42 | local exec |
43 | local icon |
44 | local terminal |
45 | local notify |
46 | local categories |
47 | local vendor |
48 | local all_categories |
49 | local mimetypes |
50 | local all_mimetypes |
51 | |
52 | for i in $* |
53 | do |
54 | case $1 in |
55 | --name|-n) shift; name="$1" ;; |
56 | --file|-f) shift; file="$1.desktop" ;; |
57 | --comment|-m) shift; comment="$1" ;; |
58 | --exec|-e) shift; exec="$1" ;; |
59 | --icon|-i) shift; icon="$1" ;; |
60 | --terminal|-t) terminal="true" ;; |
61 | --no-notify|-y) notify="false" ;; |
62 | --categories|-c) shift; categories="$1" ;; |
63 | --vendor|-v) shift; vendor="$1" ;; |
64 | --mimetypes|-x) shift; mimetypes="$1" ;; |
65 | esac |
66 | shift |
67 | done |
68 | |
69 | # sanity checks; abort if not given |
70 | #[[ -z ${name} ]] && die "minstall_desktop_icon() \$name not given." |
71 | |
72 | # some sane defaults |
73 | [[ -z ${name} ]] && name="${PNAME}" |
74 | [[ -z ${file} ]] && file="${name}.desktop" |
75 | [[ -z ${exec} ]] && exec="${name}" |
76 | [[ -z ${icon} ]] && icon="${name}.png" |
77 | [[ -z ${terminal} ]] && terminal="false" |
78 | [[ -z ${notify} ]] && notify="true" |
79 | [[ -z ${vendor} ]] && vendor="X-Magellan" |
80 | |
81 | # get all categories |
82 | if [[ -n ${categories} ]] |
83 | then |
84 | for i in $(echo ${categories} | sed "s:,:\ :g") |
85 | do |
86 | all_categories="${all_categories} --add-category ${i}" |
87 | done |
88 | fi |
89 | |
90 | # get all mimetypes |
91 | if [[ -n ${mimetypes} ]] |
92 | then |
93 | for i in $(echo ${mimetypes} | sed "s:,:\ :g") |
94 | do |
95 | all_mimetypes="${all_mimetypes} --add-mime-type ${i}" |
96 | done |
97 | fi |
98 | |
99 | echo "[Desktop Entry] |
100 | Encoding=UTF-8 |
101 | Name=${name} |
102 | Comment=${comment} |
103 | Exec=${exec} |
104 | Icon=${icon} |
105 | Terminal=${terminal} |
106 | StartupNotify=${notify} |
107 | Type=Application" > ${SRCDIR}/${file} |
108 | desktop-file-install \ |
109 | --vendor ${vendor} \ |
110 | --delete-original \ |
111 | --dir ${BINDIR}/usr/share/applications \ |
112 | --add-category X-Magellan-Application \ |
113 | ${all_categories} \ |
114 | ${all_mimetyes} \ |
115 | ${SRCDIR}/${file} \ |
116 | || die |
117 | } |
118 | |
119 | # installs already created desktop icons to application dir |
120 | # minstallxdg {-s} srcname destname {/path/to} |
121 | minstallxdg() |
122 | { |
123 | local file |
124 | local destdir |
125 | local destfile |
126 | |
127 | [[ -z "$1" ]] && die "No xdg desktop file given" |
128 | |
129 | # if no fullpath given use file from sourcedir |
130 | if [[ $1 = -s ]] |
131 | then |
132 | file="${SOURCEDIR}/${PNAME}/$2" |
133 | destfile="$3" |
134 | |
135 | else |
136 | file="$1" |
137 | fi |
138 | |
139 | if [[ $1 = -s ]] |
140 | then |
141 | file="${SOURCEDIR}/${PNAME}/$2" |
142 | if [[ -n "$3" ]] |
143 | then |
144 | destfile="$3" |
145 | else |
146 | destfile="$(basename ${file})" |
147 | fi |
148 | |
149 | if [[ -n "$4" ]] |
150 | then |
151 | destdir="$4" |
152 | else |
153 | destdir="/usr/share/applications" |
154 | fi |
155 | |
156 | else |
157 | file="$1" |
158 | if [[ -n "$2" ]] |
159 | then |
160 | destfile="$2" |
161 | else |
162 | destfile="$(basename ${file})" |
163 | fi |
164 | |
165 | if [[ -n "$3" ]] |
166 | then |
167 | destdir="$3" |
168 | else |
169 | destdir="/usr/share/applications" |
170 | fi |
171 | fi |
172 | |
173 | # needed directory |
174 | install -d ${BINDIR}/${destdir} || die |
175 | |
176 | # install our xdg |
177 | install -m 0644 -o root -g root ${file} ${BINDIR}/${destdir}/${destfile} || die |
178 | } |