1 |
Author: cardoe |
2 |
Date: 2008-02-22 19:17:19 +0000 (Fri, 22 Feb 2008) |
3 |
New Revision: 386 |
4 |
|
5 |
Added: |
6 |
trunk/modules/fontconfig.eselect |
7 |
trunk/modules/xvmc.eselect |
8 |
Log: |
9 |
adding some eselect modules I've written |
10 |
|
11 |
Added: trunk/modules/fontconfig.eselect |
12 |
=================================================================== |
13 |
--- trunk/modules/fontconfig.eselect (rev 0) |
14 |
+++ trunk/modules/fontconfig.eselect 2008-02-22 19:17:19 UTC (rev 386) |
15 |
@@ -0,0 +1,206 @@ |
16 |
+# Copyright 1999-2007 Gentoo Foundation |
17 |
+# Distributed under the terms of the GNU General Public License v2 |
18 |
+# $Header: /var/cvsroot/gentoo-x86/app-admin/eselect-fontconfig/files/fontconfig.eselect-1.0,v 1.1 2007/07/28 02:50:13 dirtyepic Exp $ |
19 |
+ |
20 |
+DESCRIPTION="Manage fontconfig /etc/fonts/conf.d/ symlinks" |
21 |
+MAINTAINER="cardoe@g.o" |
22 |
+SVN_DATE='$Date: $' |
23 |
+VERSION=$(svn_date_to_version "${SVN_DATE}") |
24 |
+ |
25 |
+find_targets() { |
26 |
+ local targets bc x i=0 |
27 |
+ bcdirs[i]="${ROOT}/etc/fonts/conf.avail/*.conf" |
28 |
+ |
29 |
+ if [[ -n "${ES_FONTCONFIG_DIRS}" ]] ; then |
30 |
+ for x in ${ES_FONTCONFIG_DIRS} ; do |
31 |
+ bcdirs[$((++i))]="${x}/*" |
32 |
+ done |
33 |
+ fi |
34 |
+ |
35 |
+ for bc in ${bcdirs[@]} ; do |
36 |
+ [[ -e ${bc} && ${bc} != *~ ]] && targets="${targets}\n$(basename ${bc})" |
37 |
+ done |
38 |
+ |
39 |
+ echo -ne ${targets} | sort -u |
40 |
+} |
41 |
+ |
42 |
+is_enabled() { |
43 |
+ bcdir="${ROOT}/etc/fonts/conf.d" |
44 |
+ |
45 |
+ [[ -e ${bcdir}/${1} ]] || return 1 |
46 |
+ return 0 |
47 |
+} |
48 |
+ |
49 |
+### list action ### |
50 |
+ |
51 |
+describe_list() { |
52 |
+ echo "List available fontconfig .conf files" |
53 |
+} |
54 |
+ |
55 |
+do_list() { |
56 |
+ local opts |
57 |
+ targets=( $(find_targets) ) |
58 |
+ write_list_start "Available fontconfig .conf files ( $(highlight '*') is enabled ):" |
59 |
+ |
60 |
+ if [[ -n "${targets[@]}" ]] ; then |
61 |
+ for (( n = 0 ; n < ${#targets[@]} ; ++n )) ; do |
62 |
+ is_enabled ${opts:-} ${targets[${n}]} && \ |
63 |
+ targets[${n}]="${targets[${n}]} $(highlight '*')" |
64 |
+ done |
65 |
+ write_numbered_list "${targets[@]}" |
66 |
+ else |
67 |
+ write_kv_list_entry "(none found)" "" |
68 |
+ fi |
69 |
+ |
70 |
+ return 0 |
71 |
+} |
72 |
+ |
73 |
+### enable action ### |
74 |
+ |
75 |
+describe_enable() { |
76 |
+ echo "Enable specified fontconfig .conf file(s)" |
77 |
+} |
78 |
+ |
79 |
+describe_enable_parameters() { |
80 |
+ echo "<target>" |
81 |
+} |
82 |
+ |
83 |
+describe_enable_options() { |
84 |
+ echo "<target> : Target name or number (from 'list' action)" |
85 |
+} |
86 |
+ |
87 |
+do_enable() { |
88 |
+ local bc bcdir="${ROOT}/etc/fonts/conf.d" |
89 |
+ |
90 |
+ [[ -z ${1} ]] && die -q "You didn't specify any .conf files to enable" |
91 |
+ |
92 |
+ # create directory if necessary |
93 |
+ if [[ ! -d ${bcdir} && -w $(dirname ${bcdir}) ]] ; then |
94 |
+ mkdir ${bcdir} || die -q "Failed to create ${bcdir}" |
95 |
+ elif [[ ! -d ${bcdir} ]] ; then |
96 |
+ die -q "You don't have permission to create ${bcdir}" |
97 |
+ fi |
98 |
+ |
99 |
+ # make sure we have proper permissions |
100 |
+ [[ -w ${bcdir} ]] || \ |
101 |
+ die -q "You don't have permission to write to ${bcdir}" |
102 |
+ |
103 |
+ targets=( $(find_targets) ) |
104 |
+ |
105 |
+ for bc in $@ ; do |
106 |
+ local file target=${bc} |
107 |
+ |
108 |
+ is_number "${target}" && \ |
109 |
+ target=${targets[$(( ${target} - 1 ))]} |
110 |
+ |
111 |
+ [[ -z "${target}" ]] && \ |
112 |
+ die -q "Target \"${bc}\" doesn't appear to be valid!" |
113 |
+ |
114 |
+ bc=${target} |
115 |
+ |
116 |
+ # ignore any unrecognized options |
117 |
+ [[ ${bc} == --* ]] && continue |
118 |
+ |
119 |
+ # what form is the argument in? |
120 |
+ case "${bc}" in |
121 |
+ # absolute path |
122 |
+ /*) |
123 |
+ file="${ROOT}/${bc}" |
124 |
+ ;; |
125 |
+ # relative path |
126 |
+ */*) |
127 |
+ file="${ROOT}/${PWD}/${bc}" |
128 |
+ ;; |
129 |
+ # no path |
130 |
+ *) |
131 |
+ # CWD |
132 |
+ if [[ -f ${bc} ]] ; then |
133 |
+ file="${ROOT}/${PWD}/${bc}" |
134 |
+ # assume /etc/fonts/conf.avail |
135 |
+ elif [[ -f ${ROOT}/etc/fonts/conf.avail/${bc} ]] |
136 |
+ then |
137 |
+ file="${ROOT}/etc/fonts/conf.avail/${bc}" |
138 |
+ else |
139 |
+ if [[ -n "${ES_FONTCONFIG_DIRS}" ]] ; then |
140 |
+ for x in ${ES_FONTCONFIG_DIRS} ; do |
141 |
+ [[ -f ${x}/${bc} ]] && file="${x}/${bc}" |
142 |
+ done |
143 |
+ fi |
144 |
+ |
145 |
+ [[ -e ${file} ]] || \ |
146 |
+ file="${ROOT}/etc/fonts/conf.avail/${bc}" |
147 |
+ fi |
148 |
+ ;; |
149 |
+ esac |
150 |
+ |
151 |
+ # does it exist? |
152 |
+ if [[ ! -e ${file} ]] ; then |
153 |
+ write_error_msg "${file} doesn't exist" |
154 |
+ continue |
155 |
+ fi |
156 |
+ |
157 |
+ # already installed? |
158 |
+ if [[ -e ${bcdir}/$(basename ${bc}) ]] ; then |
159 |
+ write_error_msg "$(basename ${bc}) is already installed" |
160 |
+ continue |
161 |
+ fi |
162 |
+ |
163 |
+ # finally, create the symlink |
164 |
+ ln -s "${file}" "${bcdir}" || \ |
165 |
+ die -q "Failed to create symlink from '${file}' to '${bcdir}'" |
166 |
+ done |
167 |
+} |
168 |
+ |
169 |
+### disable action ### |
170 |
+ |
171 |
+describe_disable() { |
172 |
+ echo "Disable specified fontconfig .conf file(s)" |
173 |
+} |
174 |
+ |
175 |
+describe_disable_parameters() { |
176 |
+ echo "<target>" |
177 |
+} |
178 |
+ |
179 |
+describe_disable_options() { |
180 |
+ echo "<target> : Target name or number (from 'list' action)" |
181 |
+} |
182 |
+ |
183 |
+ |
184 |
+do_disable() { |
185 |
+ local bc bcdir="${ROOT}/etc/fonts/conf.d" |
186 |
+ |
187 |
+ [[ -z ${1} ]] && die -q "You didn't specify any .conf files to disable" |
188 |
+ |
189 |
+ targets=( $(find_targets) ) |
190 |
+ |
191 |
+ for bc in $@ ; do |
192 |
+ local file target=${bc} |
193 |
+ |
194 |
+ is_number "${target}" && \ |
195 |
+ target=${targets[$(( ${target} - 1 ))]} |
196 |
+ |
197 |
+ [[ -z "${target}" ]] && \ |
198 |
+ die -q "Target \"${bc}\" doesn't appear to be valid!" |
199 |
+ |
200 |
+ bc=${target} |
201 |
+ file="${bcdir}/${bc}" |
202 |
+ |
203 |
+ # ignore any unrecognized options |
204 |
+ [[ ${bc} == --* ]] && continue |
205 |
+ |
206 |
+ # is in installed? |
207 |
+ if [[ ! -e ${file} ]] ; then |
208 |
+ write_error_msg "${bc} is not installed" |
209 |
+ continue |
210 |
+ fi |
211 |
+ |
212 |
+ # remove it if we have permissions |
213 |
+ if [[ -w $(dirname ${file}) ]] ; then |
214 |
+ rm "${file}" || die -q "Failed to remove ${file}" |
215 |
+ else |
216 |
+ die -q "You don't have permission to remove ${file}" |
217 |
+ fi |
218 |
+ done |
219 |
+} |
220 |
+ |
221 |
+# vim: set ft=eselect : |
222 |
|
223 |
Added: trunk/modules/xvmc.eselect |
224 |
=================================================================== |
225 |
--- trunk/modules/xvmc.eselect (rev 0) |
226 |
+++ trunk/modules/xvmc.eselect 2008-02-22 19:17:19 UTC (rev 386) |
227 |
@@ -0,0 +1,181 @@ |
228 |
+# Copyright 1999-2008 Gentoo Foundation |
229 |
+# Distributed under the terms of the GNU General Public License v2 |
230 |
+# $Id: eselect-xvmc-0.1.eselect,v 1.1 2008/02/22 14:44:40 cardoe Exp $ |
231 |
+ |
232 |
+DESCRIPTION="Manage the XvMC implementation used by your system" |
233 |
+MAINTAINER="cardoe@g.o" |
234 |
+SVN_DATE='$Date: $' |
235 |
+VERSION=$(svn_date_to_version "${SVN_DATE}" ) |
236 |
+ |
237 |
+XVMCLIBS=( |
238 |
+"libXvMCNVIDIA_dynamic.so.1" |
239 |
+"libXvMC.so.1" |
240 |
+"libviaXvMC.so.1" |
241 |
+"libchromeXvMC.so.1" |
242 |
+"libviaXvMCPro.so.1" |
243 |
+"libchromeXvMCPro.so.1" |
244 |
+"libI810XvMC.so.1" ) |
245 |
+XVMCPRETTY=( |
246 |
+"nvidia" |
247 |
+"xorg-x11" |
248 |
+"via" |
249 |
+"openchrome" |
250 |
+"via-pro" |
251 |
+"openchrome-pro" |
252 |
+"intel" ) |
253 |
+ |
254 |
+get_implementation_indices() { |
255 |
+ local ret n |
256 |
+ for (( n = 0; n < ${#XVMCLIBS[@]}; ++n )); do |
257 |
+ [[ -e "${ROOT}/usr/lib/${XVMCLIBS[n]}" ]] && ret+=($n) |
258 |
+ done |
259 |
+ |
260 |
+ echo ${ret[@]} |
261 |
+} |
262 |
+ |
263 |
+get_current_implementation_index() { |
264 |
+ local n |
265 |
+ if [[ -f "${ROOT}/etc/X11/XvMCConfig" ]]; then |
266 |
+ local current=$(< "${ROOT}/etc/X11/XvMCConfig") |
267 |
+ for (( n = 0; n < ${#XVMCLIBS[@]}; ++n )); do |
268 |
+ if [[ "${XVMCLIBS[n]}" = "${current}" ]]; then |
269 |
+ echo "${n}" |
270 |
+ return |
271 |
+ fi |
272 |
+ done |
273 |
+ fi |
274 |
+ |
275 |
+ echo "-1" |
276 |
+} |
277 |
+ |
278 |
+set_new_implementation() { |
279 |
+ echo -n "Switching to ${XVMCPRETTY[$1]} XvMC implementation..." |
280 |
+ touch "${ROOT}/etc/X11/XvMCConfig" 2&>1 > /dev/null |
281 |
+ if [[ $? -eq 0 ]]; then |
282 |
+ echo "${XVMCLIBS[$1]}" > "${ROOT}/etc/X11/XvMCConfig" |
283 |
+ chmod 644 "${ROOT}/etc/X11/XvMCConfig" |
284 |
+ chown 0:0 "${ROOT}/etc/X11/XvMCConfig" |
285 |
+ echo " done" |
286 |
+ else |
287 |
+ echo " failed!" |
288 |
+ echo "Insufficient privileges" |
289 |
+ fi |
290 |
+} |
291 |
+ |
292 |
+### list action |
293 |
+ |
294 |
+## {{{ list stuff |
295 |
+describe_list() { |
296 |
+ echo "List Available XvMC implementations" |
297 |
+} |
298 |
+ |
299 |
+do_list() { |
300 |
+ local output n |
301 |
+ local avail=( $(get_implementation_indices) ) |
302 |
+ local current=$(get_current_implementation_index) |
303 |
+ write_list_start "Available XvMC implementations ( $(highlight '*') is current ):" |
304 |
+ |
305 |
+ if (( ${#avail[@]} )) ; then |
306 |
+ for n in "${avail[@]}" ; do |
307 |
+ output[n]="${XVMCPRETTY[n]}" |
308 |
+ [[ ${current} -eq ${n} ]] && \ |
309 |
+ output[n]+=" $(highlight '*')" |
310 |
+ done |
311 |
+ write_numbered_list "${output[@]}" |
312 |
+ else |
313 |
+ write_kv_list_entry "(none found)" "" |
314 |
+ fi |
315 |
+ |
316 |
+ return 0 |
317 |
+} |
318 |
+## }}} |
319 |
+ |
320 |
+### show action |
321 |
+ |
322 |
+## {{{ show stuff |
323 |
+describe_show() { |
324 |
+ echo "Print the current XvMC implementation." |
325 |
+} |
326 |
+ |
327 |
+do_show() { |
328 |
+ local current=$(get_current_implementation_index) |
329 |
+ write_list_start "Current XvMC implementation:" |
330 |
+ |
331 |
+ if [[ ${current} -ne -1 ]]; then |
332 |
+ echo "${XVMCPRETTY[current]}" |
333 |
+ return 0 |
334 |
+ else |
335 |
+ echo "(none)" |
336 |
+ return 2 |
337 |
+ fi |
338 |
+} |
339 |
+## }}} |
340 |
+ |
341 |
+### set action |
342 |
+ |
343 |
+## {{{ set stuff |
344 |
+describe_set() { |
345 |
+ echo "Select the XvMC implementation" |
346 |
+} |
347 |
+ |
348 |
+describe_set_parameters() { |
349 |
+ echo "<target>" |
350 |
+} |
351 |
+ |
352 |
+describe_set_options() { |
353 |
+ echo "<target> : XvMC implementation to activate" |
354 |
+ echo "--use-old : If an implementation is already set, use that one instead" |
355 |
+} |
356 |
+ |
357 |
+do_set() { |
358 |
+ local current=$(get_current_implementation_index) |
359 |
+ local avail=( $(get_implementation_indices) ) |
360 |
+ local n new action |
361 |
+ |
362 |
+ while [[ ${#@} -gt 0 ]]; do |
363 |
+ local opt=${1} |
364 |
+ shift |
365 |
+ case ${opt} in |
366 |
+ --use-old) |
367 |
+ if [[ ${current} -gt -1 ]]; then |
368 |
+ (( ${current} < ${#XVMCPRETTY[@]} )) && action="old-implementation" |
369 |
+ fi |
370 |
+ ;; |
371 |
+ *) |
372 |
+ [[ -z ${action} ]] && action="set-implementation" |
373 |
+ |
374 |
+ if is_number ${opt} ; then |
375 |
+ new=${avail[opt - 1]} |
376 |
+ if [[ -z ${new} ]]; then |
377 |
+ die -q "Unrecognized option: ${opt}" |
378 |
+ fi |
379 |
+ elif has ${opt} ${XVMCPRETTY[@]}; then |
380 |
+ for (( n = 0; n < ${#XVMCPRETTY[@]}; ++n )); do |
381 |
+ [[ "${XVMCPRETTY[n]}" = "${opt}" ]] && new=${n} |
382 |
+ done |
383 |
+ else |
384 |
+ die -q "Unrecognized option: ${opt}" |
385 |
+ fi |
386 |
+ ;; |
387 |
+ esac |
388 |
+ done |
389 |
+ |
390 |
+ case ${action} in |
391 |
+ old-implementation) |
392 |
+ set_new_implementation ${current} |
393 |
+ return $? |
394 |
+ ;; |
395 |
+ set-implementation) |
396 |
+ if [[ -n ${new} ]]; then |
397 |
+ set_new_implementation ${new} |
398 |
+ return $? |
399 |
+ else |
400 |
+ die -q "Please specify an implementation to set" |
401 |
+ fi |
402 |
+ ;; |
403 |
+ *) |
404 |
+ die -q "Invalid usage of set action." |
405 |
+ esac |
406 |
+} |
407 |
+ |
408 |
+# vim: ts=4 sw=4 noet fdm=marker |
409 |
|
410 |
-- |
411 |
gentoo-commits@l.g.o mailing list |