Gentoo Archives: gentoo-commits

From: "Doug Klima (cardoe)" <cardoe@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in app-admin/eselect-xvmc/files: xvmc-0.1.eselect
Date: Fri, 22 Feb 2008 05:28:42
Message-Id: E1JSQSc-00081h-PD@stork.gentoo.org
1 cardoe 08/02/22 05:28:38
2
3 Added: xvmc-0.1.eselect
4 Log:
5 Decided to write an eselect module for XvMCWrapper. First version.
6 (Portage version: 2.1.4.4)
7
8 Revision Changes Path
9 1.1 app-admin/eselect-xvmc/files/xvmc-0.1.eselect
10
11 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-admin/eselect-xvmc/files/xvmc-0.1.eselect?rev=1.1&view=markup
12 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-admin/eselect-xvmc/files/xvmc-0.1.eselect?rev=1.1&content-type=text/plain
13
14 Index: xvmc-0.1.eselect
15 ===================================================================
16 # Copyright 1999-2008 Gentoo Foundation
17 # Distributed under the terms of the GNU General Public License v2
18 # $Id: xvmc-0.1.eselect,v 1.1 2008/02/22 05:28:38 cardoe Exp $
19
20 DESCRIPTION="Manage the XvMC implementation used by your system"
21 MAINTAINER="cardoe@g.o"
22 SVN_DATE='$Date: 2008/02/22 05:28:38 $'
23 VERSION=$(svn_date_to_version "${SVN_DATE}" )
24
25 XVMCLIBS=(
26 "libXvMCNVIDIA_dynamic.so.1"
27 "libXvMC.so.1"
28 "libviaXvMC.so.1"
29 "libchromeXvMC.so.1"
30 "libviaXvMCPro.so.1"
31 "libchromeXvMCPro.so.1"
32 "libI810XvMC.so.1" )
33 XVMCPRETTY=(
34 "nvidia"
35 "xorg-x11"
36 "via"
37 "openchrome"
38 "via-pro"
39 "openchrome-pro"
40 "intel" )
41
42 get_implementation_indices() {
43 local ret n
44 for (( n = 0; n < ${#XVMCLIBS[@]}; ++n )); do
45 [[ -e "${ROOT}/usr/lib/${XVMCLIBS[n]}" ]] && ret+=($n)
46 done
47
48 echo ${ret[@]}
49 }
50
51 get_current_implementation_index() {
52 local n
53 if [[ -f "${ROOT}/etc/X11/XvMCConfig" ]]; then
54 local current=$(< "${ROOT}/etc/X11/XvMCConfig")
55 for (( n = 0; n < ${#XVMCLIBS[@]}; ++n )); do
56 if [[ "${XVMCLIBS[n]}" = "${current}" ]]; then
57 echo "${n}"
58 return
59 fi
60 done
61 fi
62
63 echo "-1"
64 }
65
66 set_new_implementation() {
67 echo -n "Switching to ${XVMCPRETTY[$1]} XvMC implementation..."
68 touch "${ROOT}/etc/X11/XvMCConfig" 2&>1 > /dev/null
69 if [[ $? -eq 0 ]]; then
70 echo "${XVMCLIBS[$1]}" > "${ROOT}/etc/X11/XvMCConfig"
71 chmod 644 "${ROOT}/etc/X11/XvMCConfig"
72 chown 0:0 "${ROOT}/etc/X11/XvMCConfig"
73 echo " done"
74 else
75 echo " failed!"
76 echo "Insufficient privileges"
77 fi
78 }
79
80 ### list action
81
82 ## {{{ list stuff
83 describe_list() {
84 echo "List Available XvMC implementations"
85 }
86
87 do_list() {
88 local output n
89 local avail=( $(get_implementation_indices) )
90 local current=$(get_current_implementation_index)
91 write_list_start "Available XvMC implementations ( $(highlight '*') is current ):"
92
93 if (( ${#avail[@]} )) ; then
94 for n in "${avail[@]}" ; do
95 output[n]="${XVMCPRETTY[n]}"
96 [[ ${current} -eq ${n} ]] && \
97 output[n]+=" $(highlight '*')"
98 done
99 write_numbered_list "${output[@]}"
100 else
101 write_kv_list_entry "(none found)" ""
102 fi
103
104 return 0
105 }
106 ## }}}
107
108 ### show action
109
110 ## {{{ show stuff
111 describe_show() {
112 echo "Print the current XvMC implementation."
113 }
114
115 do_show() {
116 local current=$(get_current_implementation_index)
117 write_list_start "Current XvMC implementation:"
118
119 if [[ ${current} -ne -1 ]]; then
120 echo "${XVMCPRETTY[current]}"
121 return 0
122 else
123 echo "(none)"
124 return 2
125 fi
126 }
127 ## }}}
128
129 ### set action
130
131 ## {{{ set stuff
132 describe_set() {
133 echo "Select the XvMC implementation"
134 }
135
136 describe_set_parameters() {
137 echo "<target>"
138 }
139
140 describe_set_options() {
141 echo "<target> : XvMC implementation to activate"
142 echo "--use-old : If an implementation is already set, use that one instead"
143 }
144
145 do_set() {
146 local current=$(get_current_implementation_index)
147 local avail=( $(get_implementation_indices) )
148 local n new action
149
150 while [[ ${#@} -gt 0 ]]; do
151 local opt=${1}
152 shift
153 case ${opt} in
154 --use-old)
155 if [[ ${current} -gt -1 ]]; then
156 (( ${current} < ${#XVMCPRETTY[@]} )) && action="old-implementation"
157 fi
158 ;;
159 *)
160 [[ -z ${action} ]] && action="set-implementation"
161
162 if is_number ${opt} ; then
163 new=${avail[opt - 1]}
164 if [[ -z ${new} ]]; then
165 die -q "Unrecognized option: ${opt}"
166 fi
167 elif has ${opt} ${XVMCPRETTY[@]}; then
168 for (( n = 0; n < ${#XVMCPRETTY[@]}; ++n )); do
169 [[ "${XVMCPRETTY[n]}" = "${opt}" ]] && new=${n}
170 done
171 else
172 die -q "Unrecognized option: ${opt}"
173 fi
174 ;;
175 esac
176 done
177
178 case ${action} in
179 old-implementation)
180 set_new_implementation ${current}
181 return $?
182 ;;
183 set-implementation)
184 if [[ -n ${new} ]]; then
185 set_new_implementation ${new}
186 return $?
187 else
188 die -q "Please specify an implementation to set"
189 fi
190 ;;
191 *)
192 die -q "Invalid usage of set action."
193 esac
194 }
195
196 # vim: ts=4 sw=4 noet fdm=marker
197
198
199
200 --
201 gentoo-commits@l.g.o mailing list