Gentoo Archives: gentoo-commits

From: "Jorge Manuel B. S. Vicetto (jmbsvicetto)" <jmbsvicetto@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in x11-wm/compiz/files: compiz-manager
Date: Sat, 01 Nov 2008 13:19:59
Message-Id: E1KwGOT-0006oL-B4@stork.gentoo.org
1 jmbsvicetto 08/11/01 13:19:57
2
3 Added: compiz-manager
4 Log:
5 Added the missing compiz-manager file.
6 (Portage version: 2.2_rc12/cvs/Linux 2.6.27-gentoo x86_64)
7
8 Revision Changes Path
9 1.1 x11-wm/compiz/files/compiz-manager
10
11 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/x11-wm/compiz/files/compiz-manager?rev=1.1&view=markup
12 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/x11-wm/compiz/files/compiz-manager?rev=1.1&content-type=text/plain
13
14 Index: compiz-manager
15 ===================================================================
16 #!/bin/sh
17 # Compiz Manager wrapper script
18 #
19 # Copyright (c) 2007 Kristian Lyngstøl <kristian@×××××××××.org>
20 #
21 # This program is free software; you can redistribute it and/or modify
22 # it under the terms of the GNU General Public License as published by
23 # the Free Software Foundation; either version 2 of the License, or
24 # (at your option) any later version.
25 #
26 # This program is distributed in the hope that it will be useful,
27 # but WITHOUT ANY WARRANTY; without even the implied warranty of
28 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 # GNU General Public License for more details.
30 #
31 #
32 # You should have received a copy of the GNU General Public License
33 # along with this program; if not, write to the Free Software
34 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
35 #
36 #
37 # Contributions by: Treviño (3v1n0) <trevi55@×××××.com>, Ubuntu Packages
38 #
39 # Much of this code is based on Beryl code, also licensed under the GPL.
40 # This script will detect what options we need to pass to compiz to get it
41 # started, and start a default plugin and possibly window decorator.
42 #
43
44
45 COMPIZ_BIN_PATH="/usr/bin/" # For window decorators and compiz
46 PLUGIN_PATH="/usr/lib/compiz/"
47 GLXINFO="/usr/bin/glxinfo"
48 KWIN="/usr/bin/kwin"
49 METACITY="/usr/bin/metacity"
50 COMPIZ_NAME="compiz" # Final name for compiz (compiz.real)
51
52 # For Xgl LD_PRELOAD
53 LIBGL_NVIDIA="/usr/lib/nvidia/libGL.so.1.2.xlibmesa"
54 LIBGL_FGLRX="/usr/lib/fglrx/libGL.so.1.2.xlibmesa"
55
56 # Minimum amount of memory (in kilo bytes) that nVidia cards need
57 # to be allowed to start
58 # Set to 262144 to require 256MB
59 NVIDIA_MEMORY="65536" # 64MB
60 NVIDIA_SETTINGS="nvidia-settings" # Assume it's in the path by default
61
62 # For detecting what driver is in use, the + is for one or more /'s
63 XORG_DRIVER_PATH="/usr/lib/xorg/modules/drivers/+"
64
65 FALLBACKWM="${METACITY}"
66 FALLBACKWM_OPTIONS="--replace $@"
67
68 # Driver whitelist
69 WHITELIST="nvidia intel ati radeon i810"
70
71 # blacklist based on the pci ids
72 # See http://wiki.compiz-fusion.org/Hardware/Blacklist for details
73 T=" 1002:5954 1002:5854 1002:5955" # ati rs480
74 T="$T 1002:4153" # ATI Rv350
75 T="$T 8086:2982 8086:2992 8086:29a2 8086:2a02 8086:2a12" # intel 965
76 BLACKLIST_PCIIDS="$T"
77 unset T
78
79 COMPIZ_OPTIONS="--ignore-desktop-hints --replace"
80 COMPIZ_PLUGINS=""
81 ENV=""
82
83 # Use emerald by default if it exist
84 USE_EMERALD="yes"
85
86 # No indirect by default
87 INDIRECT="no"
88
89 # Default X.org log if xset q doesn't reveal it
90 XORG_DEFAULT_LOG="/var/log/Xorg.0.log"
91
92 # Set to yes to enable verbose
93 VERBOSE="yes"
94
95 # Echos the arguments if verbose
96 verbose()
97 {
98 if [ "x$VERBOSE" = "xyes" ]; then
99 printf "$*"
100 fi
101 }
102
103 # abort script and run fallback windowmanager
104 abort_with_fallback_wm()
105 {
106 if [ "x$SKIP_CHECKS" = "xyes" ]; then
107 verbose "SKIP_CHECKS is yes, so continuing despite problems.\n"
108 return 0;
109 fi
110
111 verbose "aborting and using fallback: $FALLBACKWM \n"
112
113 if [ -x $FALLBACKWM ]; then
114 exec $FALLBACKWM $FALLBACKWM_OPTIONS
115 else
116 printf "no $FALLBACKWM found, exiting\n"
117 exit 1
118 fi
119 }
120
121 # Check for non power of two texture support
122 check_npot_texture()
123 {
124 verbose "Checking for non power of two support: "
125 if glxinfo 2> /dev/null | egrep -q '(GL_ARB_texture_non_power_of_two|GL_NV_texture_rectangle|GL_EXT_texture_rectangle|GL_ARB_texture_rectangle)' ; then
126 verbose "present. \n";
127 return 0;
128 else
129 verbose "Not present. \n"
130 return 1;
131 fi
132
133 }
134
135 # Check for presence of FBConfig
136 check_fbconfig()
137 {
138 verbose "Checking for FBConfig: "
139 if [ "$INDIRECT" = "yes" ]; then
140 $GLXINFO -i | grep -q GLX.*fbconfig
141 FB=$?
142 else
143 $GLXINFO | grep -q GLX.*fbconfig
144 FB=$?
145 fi
146
147 if [ $FB = "0" ]; then
148 unset FB
149 verbose "present. \n"
150 return 0;
151 else
152 unset FB
153 verbose "not present. \n"
154 return 1;
155 fi
156 }
157
158
159 # Check for TFP
160 check_tfp()
161 {
162 verbose "Checking for texture_from_pixmap: "
163 if [ $($GLXINFO 2>/dev/null | grep GLX_EXT_texture_from_pixmap -c) -gt 2 ] ; then
164 verbose "present. \n"
165 return 0;
166 else
167 verbose "not present. \n"
168 if [ "$INDIRECT" = "yes" ]; then
169 unset LIBGL_ALWAYS_INDIRECT
170 INDIRECT="no"
171 return 1;
172 else
173 verbose "Trying again with indirect rendering:\n";
174 INDIRECT="yes"
175 export LIBGL_ALWAYS_INDIRECT=1
176 check_tfp;
177 return $?
178 fi
179 fi
180 }
181
182 # Check wether the composite extension is present
183 check_composite()
184 {
185 verbose "Checking for Composite extension: "
186 if xdpyinfo -queryExtensions | grep -q Composite ; then
187 verbose "present. \n";
188 return 0;
189 else
190 verbose "not present. \n";
191 return 1;
192 fi
193 }
194
195 # Detects if Xgl is running
196 check_xgl()
197 {
198 verbose "Checking for Xgl: "
199 if xvinfo | grep -q Xgl ; then
200 verbose "present. \n"
201 return 0;
202 else
203 verbose "not present. \n"
204 return 1;
205 fi
206 }
207
208 # Check if the nVidia card has enough video ram to make sense
209 check_nvidia_memory()
210 {
211 MEM=$(${NVIDIA_SETTINGS} -q VideoRam | egrep Attribute\ \'VideoRam\'\ .*: | cut -d: -f3 | sed 's/[^0-9]//g')
212 if [ $MEM -lt $NVIDIA_MEMORY ]; then
213 verbose "Less than ${NVIDIA_MEMORY}kb of memory and nVidia";
214 return 1;
215 fi
216 return 0;
217 }
218
219 # Check for existence if NV-GLX
220 check_nvidia()
221 {
222 if [ ! -z $NVIDIA_INTERNAL_TEST ]; then
223 return $NVIDIA_INTERNAL_TEST;
224 fi
225 verbose "Checking for nVidia: "
226 if xdpyinfo | grep -q NV-GLX ; then
227 verbose "present. \n"
228 NVIDIA_INTERNAL_TEST=0
229 return 0;
230 else
231 verbose "not present. \n"
232 NVIDIA_INTERNAL_TEST=1
233 return 1;
234 fi
235 }
236
237 # Check if the max texture size is large enough compared to the resolution
238 check_texture_size()
239 {
240 TEXTURE_LIMIT=$(glxinfo -l | grep GL_MAX_TEXTURE_SIZE | sed 's/.*=[^0-9]//g')
241 RESOLUTION=$(xdpyinfo | grep -i dimensions: | sed 's/[^0-9]*pixels.*(.*).*//' | sed 's/[^0-9x]*//')
242 VRES=$(echo $RESOLUTION | sed 's/.*x//')
243 HRES=$(echo $RESOLUTION | sed 's/x.*//')
244 verbose "Comparing resolution ($RESOLUTION) to maximum 3D texture size ($TEXTURE_LIMIT): ";
245 if [ $VRES -gt $TEXTURE_LIMIT ] || [ $HRES -gt $TEXTURE_LIMIT ]; then
246 verbose "Failed.\n"
247 return 1;
248 fi
249 verbose "Passed.\n"
250 return 0
251 }
252
253 # check driver whitelist
254 running_under_whitelisted_driver()
255 {
256 LOG=$(xset q|grep "Log file"|awk '{print $3}')
257 if [ "$LOG" = "" ]; then
258 verbose "xset q doesn't reveal the location of the log file. Using fallback $XORG_DEFAULT_LOG \n"
259 LOG=$XORG_DEFAULT_LOG;
260 fi
261 if [ -z "$LOG" ];then
262 verbose "AIEEEEH, no Log file found \n"
263 verbose "$(xset q) \n"
264 return 0
265 fi
266 for DRV in ${WHITELIST}; do
267 if egrep -q "Loading ${XORG_DRIVER_PATH}${DRV}_drv\.so" $LOG &&
268 ! egrep -q "Unloading ${XORG_DRIVER_PATH}${DRV}_drv\.so" $LOG;
269 then
270 return 0
271 fi
272 done
273 verbose "No whitelisted driver found\n"
274 return 1
275 }
276
277 # check pciid blacklist
278 have_blacklisted_pciid()
279 {
280 OUTPUT=$(lspci -n)
281 for ID in ${BLACKLIST_PCIIDS}; do
282 if echo "$OUTPUT" | egrep -q "$ID"; then
283 verbose "Blacklisted PCIID '$ID' found \n"
284 return 0
285 fi
286 done
287 OUTPUT=$(lspci -vn | grep -i VGA)
288 verbose "Detected PCI ID for VGA: $OUTPUT\n"
289 return 1
290 }
291
292 build_env()
293 {
294 if check_nvidia; then
295 ENV="__GL_YIELD=NOTHING "
296 fi
297 if [ "$INDIRECT" = "yes" ]; then
298 ENV="$ENV LIBGL_ALWAYS_INDIRECT=1 "
299 fi
300 if check_xgl; then
301 if [ -f ${LIBGL_NVIDIA} ]; then
302 ENV="$ENV LD_PRELOAD=${LIBGL_NVIDIA}"
303 verbose "Enabling Xgl with nVidia drivers...\n"
304 fi
305 if [ -f ${LIBGL_FGLRX} ]; then
306 ENV="$ENV LD_PRELOAD=${LIBGL_FGLRX}"
307 verbose "Enabling Xgl with fglrx ATi drivers...\n"
308 fi
309 fi
310
311 ENV="$ENV FROM_WRAPPER=yes"
312
313 if [ -n "$ENV" ]; then
314 export $ENV
315 fi
316 }
317
318 build_args()
319 {
320 if [ $INDIRECT = "yes" ]; then
321 COMPIZ_OPTIONS="$COMPIZ_OPTIONS --indirect-rendering "
322 fi
323 if check_nvidia; then
324 COMPIZ_OPTIONS="$COMPIZ_OPTIONS --loose-binding"
325 fi
326 }
327
328 ####################
329 # Execution begins here.
330
331 # Read configuration from XDG paths
332 if [ -z "$XDG_CONFIG_DIRS" ]; then
333 test -f /etc/xdg/compiz/compiz-manager && . /etc/xdg/compiz/compiz-manager
334 else
335 test -f $XDG_CONFIG_DIRS/compiz/compiz-manager && . $XDG_CONFIG_DIRS/compiz/compiz-manager
336 fi
337
338 if [ -z "$XDG_CONFIG_HOME" ]; then
339 test -f $HOME/.config/compiz/compiz-manager && . $HOME/.config/compiz/compiz-manager
340 else
341 test -f $XDG_CONFIG_HOME/compiz/compiz-manager && . $XDG_CONFIG_HOME/compiz/compiz-manager
342 fi
343
344 # Don't use compiz when running the failsafe session
345 if [ "x$GNOME_DESKTOP_SESSION_ID" = "xFailsafe" ]; then
346 abort_with_fallback_wm
347 fi
348
349 if [ "x$LIBGL_ALWAYS_INDIRECT" = "x1" ]; then
350 INDIRECT="yes";
351 fi
352
353 # if we run under Xgl, we can skip some tests here
354 if ! check_xgl; then
355 # if vesa or vga are in use, do not even try glxinfo (LP#119341)
356 if ! running_under_whitelisted_driver || have_blacklisted_pciid; then
357 abort_with_fallback_wm
358 fi
359 # check if we have the required bits to run compiz and if not,
360 # fallback
361 if ! check_tfp || ! check_npot_texture || ! check_composite || ! check_texture_size; then
362 abort_with_fallback_wm
363 fi
364
365 if check_nvidia && ! check_nvidia_memory; then
366 abort_with_fallback_wm
367 fi
368
369 if ! check_fbconfig; then
370 abort_with_fallback_wm
371 fi
372 fi
373
374 # load the ccp plugin if present and fallback to plain gconf if not
375 if [ -f ${PLUGIN_PATH}libccp.so ]; then
376 COMPIZ_PLUGINS="$COMPIZ_PLUGINS ccp"
377 elif [ -f ${PLUGIN_PATH}libgconf.so ]; then
378 COMPIZ_PLUGINS="$COMPIZ_PLUGINS glib gconf"
379 fi
380
381 # get environment
382 build_env
383 build_args
384
385 # start the gtk-window-decorator if present
386 if [ -x ${COMPIZ_BIN_PATH}emerald ] && [ "$USE_EMERALD" = "yes" ]; then
387 verbose "Starting emerald\n"
388 ${COMPIZ_BIN_PATH}emerald --replace &
389 elif [ -x ${COMPIZ_BIN_PATH}gtk-window-decorator ] && [ -n "$GNOME_DESKTOP_SESSION_ID" ]; then
390 verbose "Starting gtk-window-decorator\n"
391 ${COMPIZ_BIN_PATH}gtk-window-decorator --replace &
392 elif [ -x ${COMPIZ_BIN_PATH}kde-window-decorator ] && [ -n "$KDE_FULL_SESSION" ]; then
393 verbose "Starting kde-window-decorator\n"
394 ${COMPIZ_BIN_PATH}kde-window-decorator --replace &
395 FALLBACKWM="${KWIN}"
396 fi
397
398 ${COMPIZ_BIN_PATH}${COMPIZ_NAME} $COMPIZ_OPTIONS "$@" $COMPIZ_PLUGINS || exec $FALLBACKWM $FALLBACKWM_OPTIONS