#!/bin/bash # # Copyright (c) 2008, by Sun Microsystems, Inc. # Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. # # Checks if compiz can run with the current Xserver # display settings. If this is not the case # marco is started instead. # MARCO="/usr/bin/marco --replace --sm-client-id=default0" GREP="/usr/bin/grep" XDPYINFO="/usr/bin/xdpyinfo" GLXINFO="/usr/bin/glxinfo" XPROP="/usr/bin/xprop" SED="/usr/bin/sed" GSETTINGSTOOL="/usr/bin/gsettings" COMPIZ_BIN="/usr/bin/compiz-bin" COMPIZ_OPTIONS="--fast-filter --replace" COMPIZ_PLUGINS="ccp" GSETTINGS_A11Y_KEY="org.mate.interface accessibility" DECORATOR="/usr/bin/gtk-window-decorator" DECORATOR_OPTIONS="--replace" if [ "x$COMPIZ_VERBOSE" != "x" ]; then VERBOSE="yes" else VERBOSE="no" fi verbose() { if [ "x$VERBOSE" = "xyes" ]; then echo "$*" fi } abort_with_marco() { verbose "Cannot run compiz starting marco instead\n" exec $MARCO } # Check wether the composite extension is present check_composite() { verbose "Checking for Composite extension: " if $XDPYINFO -queryExtensions | $GREP -q Composite ; then verbose "present. \n" return 0 else verbose "not present. \n" return 1 fi } # Check wether we are in a sunray session check_sunray_session() { verbose "Checking for Sunray session: " if $XPROP -root | $GREP -q _SUN_SUNRAY_HOME ; then verbose "present. \n" return 1 else verbose "not present. \n" return 0 fi } # Check wether the Xserver trusted extension is enabled check_trusted_session() { verbose "Checking for Trusted session: " if $XDPYINFO -queryExtensions | $GREP -q SUN_TSOL ; then verbose "present. \n" return 1 else verbose "not present.\n" return 0 fi } # Check whether we're running under vnc check_vnc() { verbose "Checking for VNC" HAZ_VNC=$(LC_ALL=C $GLXINFO 2>&1 | $GREP "Software Rasterizer") if [ -n "$HAZ_VNC" ] ; then verbose "Running under vnc" return 1 else verbose "Running without vnc" return 0 fi } # Check whether accessibility is turn on or not check_accessibility() { verbose "Checking for Acessibility: " a11y_value="`$GSETTINGSTOOL get $GSETTINGS_A11Y_KEY`" if [ "x$a11y_value" = "xtrue" ]; then verbose "Enabled. \n" return 1 else verbose "Disabled. \n" return 0 fi } # Check which card is present and add the right # environment variables set_env_variables() { verbose "env. variables used : " if [ -x /usr/X/bin/constype -a "`/usr/X/bin/constype`" = "NVDAnvda" ]; then __GL_SYNC_TO_VBLANK=1 export __GL_SYNC_TO_VBLANK verbose "__GL_SYNC_TO_VBLANK=1\n" __GL_YIELD=NOTHING export __GL_YIELD verbose "__GL_YIELD=1\n" else # either intel or ati INTEL_BATCH=1 export INTEL_BATCH verbose "INTEL_BATCH=1\n" fi verbose "\n" } # # Main routine of the script # check_accessibility if [ $? -eq 1 ] ; then abort_with_marco fi check_trusted_session if [ $? -eq 1 ] ; then abort_with_marco fi check_sunray_session if [ $? -eq 1 ] ; then abort_with_marco fi check_composite if [ $? -eq 1 ] ; then abort_with_marco fi check_vnc if [ $? -eq 1 ] ; then abort_with_marco fi set_env_variables # get number of screens NUM_SCREEN=`$XDPYINFO | $GREP "number of screens" | sed "s/number of screens: //"` # start one gtk-window-decorator per screen NUM_SCREEN="$NUM_SCREEN-1" for (( i = 0 ; i <= $NUM_SCREEN; i++ )) do $DECORATOR $DECORATOR_OPTIONS --display=:0.$i & done $COMPIZ_BIN "$@" $COMPIZ_OPTIONS $COMPIZ_PLUGINS $COMPIZ_INDIRECT || abort_with_marco