summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Lyngstøl <kristian@albus.(none)>2007-09-17 13:52:45 +0200
committerKristian Lyngstøl <kristian@albus.(none)>2007-09-17 13:52:45 +0200
commite48163d6eb7b99fcc16d96a5762b7a20cf56224a (patch)
treec74c1faa4f4a8287e6e06289bca20f1cdbf1e204
parente6eaabc9cdd8eccf6350de4402e7a10898a22608 (diff)
downloadcompiz-scripts-e48163d6eb7b99fcc16d96a5762b7a20cf56224a.tar.gz
compiz-scripts-e48163d6eb7b99fcc16d96a5762b7a20cf56224a.tar.bz2
Redo for /bin/sh without config storage
-rwxr-xr-xmanager/compiz-manager315
1 files changed, 84 insertions, 231 deletions
diff --git a/manager/compiz-manager b/manager/compiz-manager
index f7412b2..2dae801 100755
--- a/manager/compiz-manager
+++ b/manager/compiz-manager
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# Compiz manager
# Copyright (c) 2007 Kristian Lyngstøl <kristian@bohemians.org>
#
@@ -36,14 +36,8 @@
# The generated configuration file should be equally documented. #
#########################################################################
-# Defaults
-# Configuration file is based on XDG base dir. Set this to override the
-# defaults. Leave empty if in doubt. Use -v to see exactly what
-# configuration files compiz-manager looks for on your system.
-#CONFIG="./compiz-managerrc"
-
# Set to yes to enable verbose (-v) by default.
-VERBOSE="no"
+VERBOSE="yes"
# Default arguments. Others are added to this, and the configuration can
# override ALL arguments.
@@ -75,10 +69,10 @@ TASK="normal"
INDIRECT=1
# Echos the arguments if verbose
-function verbose
+verbose()
{
if [ "x$VERBOSE" = "xyes" ]; then
- echo -ne "$*"
+ echo -n "$*"
fi
}
@@ -88,7 +82,7 @@ function verbose
# start compiz.
# Check wether the composite extension is present
-function check_composite
+check_composite()
{
verbose "Checking for Composite extension: "
if xdpyinfo -queryExtensions | grep -q Composite ; then
@@ -100,7 +94,7 @@ function check_composite
fi
}
-function check_xdamage
+check_xdamage()
{
verbose "Checking for XDamage extension: "
if xdpyinfo -queryExtensions | grep -q DAMAGE ; then
@@ -112,7 +106,7 @@ function check_xdamage
fi
}
# Check for existence if NV-GLX
-function check_nvidia
+check_nvidia()
{
verbose "Checking for nVidia: "
if xdpyinfo | grep -q NV-GLX ; then
@@ -125,7 +119,7 @@ function check_nvidia
}
# Detects if Xgl is running
-function check_xgl
+check_xgl()
{
verbose "Checking for Xgl: "
if xvinfo | grep -q Xgl ; then
@@ -138,7 +132,7 @@ function check_xgl
}
# Check for presence of FBConfig
-function check_fbconfig
+check_fbconfig()
{
verbose "Checking for FBConfig: "
if glxinfo 2> /dev/null | grep -q GLX_SGIX_fbconfig ; then
@@ -151,7 +145,7 @@ function check_fbconfig
}
# Check for TFP
-function check_tfp
+check_tfp()
{
verbose "Checking for texture_from_pixmap: "
if [ `glxinfo 2>/dev/null | grep GLX_EXT_texture_from_pixmap -c` -gt 2 ] ; then
@@ -164,7 +158,7 @@ function check_tfp
INDIRECT=1
return 1;
else
- verbose "Trying again with indirect rendering:\n";
+ verbose "Trying again with indirect rendering:";
INDIRECT=0
export LIBGL_ALWAYS_INDIRECT=1
check_tfp;
@@ -174,7 +168,7 @@ function check_tfp
}
# Check for non power of two texture support
-function check_npot_texture
+check_npot_texture()
{
verbose "Checking for non power of two support: "
if glxinfo | egrep -q '(GL_ARB_texture_non_power_of_two|GL_NV_texture_rectangle|GL_EXT_texture_rectangle|GL_ARB_texture_rectangle)' ; then
@@ -187,7 +181,7 @@ function check_npot_texture
}
-function check_xsync
+check_xsync()
{
verbose "Checking for XSync extension: ";
if xdpyinfo -queryExtensions | grep -q SYNC ; then
@@ -200,22 +194,23 @@ function check_xsync
# Counts how many screens we have, and the base value for DISPLAY=
# so we can easily start one decorator per screen
-function check_multiscreen
+check_multiscreen()
{
SCREENS=$(xdpyinfo | grep "screen #" | wc -l)
verbose "Detected $SCREENS screen(s)\n";
- if [ "$SCREENS" == "1" ]; then return 0; fi;
- verbose "Multiscreen enviromental detection: \n"
+ if [ "$SCREENS" = "1" ]; then return 0; fi;
+ verbose "Multiscreen enviromental detection: "
DISPLAYBASE=$(xdpyinfo | grep name\ of\ display | sed 's/.* display: *//' | sed 's/\..*//')
- verbose "\tDetected $DISPLAYBASE as the base of the DISPLAY variable\n";
+ verbose "\tDetected $DISPLAYBASE as the base of the DISPLAY variable";
SCREENNUMBERS=$(xdpyinfo | grep "screen #" | sed -r 's/screen #(.):/\1/')
for a in $SCREENNUMBERS ; do
MULTIDISPLAY[$a]=${DISPLAYBASE}.$a
- verbose "\tMULTIDISPLAY[$a] set to: ${MULTIDISPLAY[$a]}\n";
+# verbose "\tMULTIDISPLAY[$a] set to: ${MULTIDISPLAY[$a]}";
+
done
}
-function possible_check
+possible_check()
{
if [ ! "$1" ]; then
echo "Fatal: Failed test: $2";
@@ -224,7 +219,7 @@ function possible_check
return 0;
}
# Returns true if we think it's actually possible to start compiz
-function check_possible
+check_possible()
{
POSSIBLE="1"
if ! possible_check "$TFP" "texture_from_pixmap support"; then return 1; fi
@@ -241,7 +236,7 @@ function check_possible
### Work functions
# Builds a new-line seperated string of enviromental variables we might want
-function build_env
+build_env()
{
if [ $NVIDIA -eq 0 ]; then
ENV="__GL_YIELD=NOTHING "
@@ -252,9 +247,9 @@ function build_env
}
# Builds the argument list
-function build_args
+build_args()
{
- if [ $NVIDIA -eq 0 -a $XGL -ne 0 -a $INDIRECT -ne 0 ]; then
+ if [ $NVIDIA -eq 0 -a $XGL 0 -a $INDIRECT 0 ]; then
ARGS="--loose-binding "$ARGS
fi
if [ $INDIRECT -eq 0 ]; then
@@ -264,195 +259,107 @@ function build_args
# Prints usage
-function usage
+usage()
{
- echo "Usage: $0 [-r <env|args>] [-v] [-h] [-i] [-f] [-d] [-w]"
- echo -e "-r\toutputs recommended values for either "
- echo -e " \tenviromental variables, or arguments."
- echo -e "-v\tVerbose: Output the result of each individual test"
- echo -e "-h\tDisplay this message";
- echo -e "-i\tIgnore config file(s)";
- echo -e "-f\tForce; This overwrites your existing config file."
- echo -e "-d\tDry run: Do everything, but don't start."
- echo -e "-w\tOnly start window decorator(s). One per screen.";
- echo -e "Configuration"
- echo -e "$0 automatically stores configuration the first time you run it.";
- echo -e "You can use that to override checks, or pass custom arguments."
- echo -e "To re-write the configuration, you can either use -f, to get one"
- echo -e "based on your own settings, or -fi to create a fresh config."
+ echo "Usage: $0 [-r <env|args>] [-v] [-h] [-d] [-w]"
+ echo "-r\toutputs recommended values for either "
+ echo " \tenviromental variables, or arguments."
+ echo "-v\tVerbose: Output the result of each individual test"
+ echo "-h\tDisplay this message";
+ echo "-d\tDry run: Do everything, but don't start."
+ echo "-w\tOnly start window decorator(s). One per screen.";
}
# Parses options
-function parse_options
-{
- while getopts "r:vhifdw" ARG
- do
- if [ "x$ARG" = "xr" ]; then
- TASK="RECOMMEND";
- if [ "x$OPTARG" = "xenv" ]; then
- REC="env";
- elif [ "x$OPTARG" = "xargs" ]; then
- REC="args"
- elif [ "x$OPTARG" = "xboth" ]; then
- REC="both"
- else
- echo "Invalid recommend argument"
- usage
- exit 1
- fi
- elif [ "x$ARG" = "xv" ]; then
- VERBOSE="yes"
- elif [ "x$ARG" = "xi" ]; then
- no_config
- IGNORECONFIG="yes"
- elif [ "x$ARG" = "xd" ]; then
- DRY="yes"
- elif [ "x$ARG" = "xf" ]; then
- FORCE="yes"
- FORCECONFIG="yes"
- elif [ "x$ARG" = "xw" ]; then
- TASK="WINDOWDECORATOR";
- else
- usage
- exit 0
- fi
- done
-}
-
-# Store configuration
-function store_config
+parse_options()
{
- if [ -n "$IGNORECONFIG" ]; then
- if [ "x$FORCECONFIG" != "xyes" ]; then return; fi;
- fi
- if [ -z $CONFIG ]; then return ; fi
- if [ -f $CONFIG ]; then
- if [ "x$FORCECONFIG" != "xyes" ]; then
- verbose "Not writing config; allready exists.\n";
- return 1;
- fi;
- fi;
- echo Writing configuration to: $CONFIG
- echo "# Autogenerated configuration" > $CONFIG
- echo "# Generated:" `date` >> $CONFIG
- echo "# On $HOSTNAME by $USER" >> $CONFIG
- echo >> $CONFIG
- echo "# Behavior references: (yes/no)" >> $CONFIG
- echo "# Set this to \"yes\" to get the same result as if you ran compiz-manager with -v" >> $CONFIG
- echo "#VERBOSE=$VERBOSE" >> $CONFIG
- echo >> $CONFIG
- echo "# Plugins" >> $CONFIG
- echo "PLUGINS=\"$PLUGINS\"" >> $CONFIG
- echo "# Or, to append: " >> $CONFIG
- echo "# PLUGINS=\"\$PLUGINS <... >\"" >> $CONFIG
- echo >> $CONFIG
- echo "# Arguments, same as plugins to append" >> $CONFIG
- echo "# ARGS=\"\$ARGS <... >\"" >> $CONFIG
- echo "#ARGS=\"$ARGS\"" >> $CONFIG
- echo >> $CONFIG
- echo "# Screen detection: " >> $CONFIG
- echo "SCREENS=$SCREENS" >> $CONFIG
- if [ -n "$SCREENNUMBERS" ]; then
- echo "SCREENNUMBERS=\"$SCREENNUMBERS\"" >> $CONFIG
- for a in ${SCREENNUMBERS}; do
- echo "MULTIDISPLAY[$a]=${MULTIDISPLAY[$a]}" >> $CONFIG
- done
+ for a in $*; do
+ if [ "$a" = "-v" ]; then
+ VERBOSE="yes";
+ elif [ "$a" = "-d" ]; then
+ DRY="yes";
+ elif [ "$a" = "-r env" ]; then
+ REC="env";
+ elif [ "$a" = "-r args" ]; then
+ REC="args";
+ elif [ "$a" = "-r both" ]; then
+ REC="both"
+ elif [ "$a" = "-w" ]; then
+ TASK="WINDOWDECORATOR"
+ else
+ usage
+ exit
fi
- echo >> $CONFIG
- echo "# Decorator" >> $CONFIG
- echo "# Use \"unset DECORATOR\" or set DECORATOR=\"\" to not use one." >> $CONFIG
- echo "DECORATOR=\"$DECORATOR\"" >> $CONFIG
- echo "DECORATORARGS=\"$DECORATORARGS\"" >> $CONFIG
- echo "# Delay in seconds before the decorator is started." >> $CONFIG
- echo "DELAY=\"$DELAY\"" >> $CONFIG
- echo "# Set this to \"no\" to send all decorator errors to /dev/null" >> $CONFIG
- echo "DECOERRORS=\"$DECOERRORS\"" >> $CONFIG
- echo >> $CONFIG
- echo "# Values of 0 mean \"true\" (present), values of 1 means \"false\" (not present)" >> $CONFIG
- echo "# Checks: " >> $CONFIG
- echo NVIDIA=$NVIDIA >> $CONFIG
- echo FBCONFIG=$FBCONFIG >> $CONFIG
- echo XGL=$XGL >> $CONFIG
- echo TFP=$TFP >> $CONFIG
- echo NPOT=$NPOT >> $CONFIG
- echo COMPOSITE=$COMPOSITE >> $CONFIG
- echo XDAMAGE=$XDAMAGE >> $CONFIG
- echo POSSIBLE=$POSSIBLE >> $CONFIG
- echo XSYNC=$XSYNC >> $CONFIG
- echo INDIRECT=$INDIRECT >> $CONFIG
+ done
}
####
# Execute checks, if necesarry.
-function check_everything
+check_everything()
{
if [ -z "$NVIDIA" ]; then
check_nvidia
NVIDIA=$?
else
- verbose "Skipping nVidia check, using stored value.\n"
+ verbose "Skipping nVidia check, using stored value."
fi
if [ -z "$XGL" ]; then
check_xgl
XGL=$?
else
- verbose "Skipping Xgl check, using stored value.\n"
+ verbose "Skipping Xgl check, using stored value."
fi
if [ -z "$FBCONFIG" ]; then
check_fbconfig
FBCONFIG=$?
else
- verbose "Skipping FBConfig check, using stored value.\n"
+ verbose "Skipping FBConfig check, using stored value."
fi
- if [ -z "$TFP" ]; then
check_tfp
TFP=$?
- else
- verbose "Skipping texture_from_pixmap check, using stored value.\n"
- fi
if [ -z "$NPOT" ]; then
check_npot_texture
NPOT=$?
else
- verbose "Skipping non-power-of-two texture check, using stored value.\n"
+ verbose "Skipping non-power-of-two texture check, using stored value."
fi
if [ -z "$COMPOSITE" ]; then
check_composite
COMPOSITE=$?
else
- verbose "Skipping Composite extension check, using stored value.\n"
+ verbose "Skipping Composite extension check, using stored value."
fi
if [ -z "$XDAMAGE" ]; then
check_xdamage
XDAMAGE=$?
else
- verbose "Skipping Damage extension check, using stored value.\n"
+ verbose "Skipping Damage extension check, using stored value."
fi
if [ -z "$XSYNC" ]; then
check_xsync
XSYNC=$?
else
- verbose "Skipping XSync extension check, using stored value.\n";
+ verbose "Skipping XSync extension check, using stored value.";
fi
if [ -z "$SCREENS" ]; then
check_multiscreen
else
- verbose "Skipping screen detection check, using stored value.\n";
+ verbose "Skipping screen detection check, using stored value.";
fi
}
###
# Check if a directory exists; creates it if it doesn't, returns false if the
# path isn't a directory.
-function require_dir
+require_dir()
{
if ! [ -a "$1" ]; then
- verbose "Creating directory $1\n";
+ verbose "Creating directory $1";
mkdir $1;
fi
if [ ! -d $1 ]; then
@@ -472,7 +379,7 @@ function require_dir
# in mind, an general errors.
# No config, so unset and possibly warn. (Might do more later)
-function no_config
+no_config()
{
if [ -n "$1" ]; then
echo "$1";
@@ -480,58 +387,9 @@ function no_config
unset CONFIG
}
-function get_config_name
-{
- if [ -n "$CONFIG" ]; then
- return 0;
- fi
-
- if [ -z "$XDG_CONFIG_HOME" ]; then
- if ! require_dir "$HOME/.config" ; then
- no_config "Don't know how to treat config files. Ignoring them."
- else
- CONFIG="$HOME/.config/compiz-managerrc"
- fi
- else
- if ! require_dir "$XDG_CONFIG_HOME" ; then
- no_config "Don't know how to treat config files. Ignoring them."
- else
- CONFIG="$XDG_CONFIG_HOME/compiz-managerrc"
- fi
- fi
-}
-
-function parse_config
-{
- if [ -z "$XDG_CONFIG_DIRS" ]; then
- XDG_CONFIG_DIRS="/etc/xdg/";
- fi
-
- verbose "Looking for configuration file(s): \n"
- oldIFS=$IFS
- IFS=":";
- for a in $XDG_CONFIG_DIRS; do
- if [ -f "$a/compiz-managerrc" ]; then
- verbose "\t Loading ${a}/compiz-managerrc\n";
- . $a/compiz-managerrc;
- else
- verbose "\t Not found: ${a}/compiz-managerrc\n";
- fi
- done
- IFS=$oldIFS
- if [ -n "$CONFIG" ]; then
- if [ -f "$CONFIG" ]; then
- verbose "\t Loading $CONFIG\n"
- . $CONFIG ;
- else
- verbose "\t Not found: \"$CONFIG\"\n";
- fi
- fi
-}
-
###
# Let's get this show started!
-function start_compiz
+start_compiz()
{
###
# No need to continue if we've determined it's not possible to start anyway
@@ -539,23 +397,23 @@ function start_compiz
echo "Checks indicate that it's impossible to start compiz on your system."
exit 1;
else
- verbose "Checks indicate compiz should work on your system\n"
+ verbose "Checks indicate compiz should work on your system"
fi;
- verbose "Exporting: $ENV \n"
+ verbose "Exporting: $ENV "
export $ENV
- verbose Executing: compiz $ARGS $PLUGINS "\n"
+ verbose Executing: compiz $ARGS $PLUGINS ""
if [ "x$DRY" = "xyes" ]; then exit 0; fi
compiz $ARGS $PLUGINS
}
####
# Starts one decorator per screen
-function start_decorators
+start_decorators()
{
if [ -z "$DECORATOR" ]; then return 1; fi
if [ "$SCREENS" == "1" ]; then
verbose "Starting delayed decorator in the background: "
- verbose "sleep $DELAY && $DECORATOR $DECORATORARGS &\n"
+ verbose "sleep $DELAY && $DECORATOR $DECORATORARGS &"
if [ "x$DRY" = "xyes" ]; then return 0; fi
if [ "$DECOERRORS" = "no" ]; then
sleep $DELAY && $DECORATOR $DECORATORARGS 2>/dev/null &
@@ -564,15 +422,14 @@ function start_decorators
fi
return 0;
fi
- verbose "Starting decorators for all screens: \n"
+ verbose "Starting decorators for all screens: "
for a in $SCREENNUMBERS; do
verbose "\t Screen $a: "
- verbose "sleep $DELAY && DISPLAY=${MULTIDISPLAY[$a]} $DECORATOR $DECORATORARGS\n"
if [ "x$DRY" != "xyes" ]; then
if [ "$DECOERRORS" = "no" ]; then
- sleep $DELAY && DISPLAY=${MULTIDISPLAY[$a]} $DECORATOR $DECORATORARGS 2>/dev/null &
+ sleep $DELAY && DISPLAY=${MULTIDISPLAY}$a $DECORATOR $DECORATORARGS 2>/dev/null &
else
- sleep $DELAY && DISPLAY=${MULTIDISPLAY[$a]} $DECORATOR $DECORATORARGS &
+ sleep $DELAY && DISPLAY=${MULTIDISPLAY}$a $DECORATOR $DECORATORARGS &
fi
fi
@@ -585,26 +442,24 @@ function start_decorators
# Check everything if necesarry, build the enviroment and arguments
# and eventually select a task.
-parse_options $*
-
-# We need this even when ignoring, or we won't know where to store force
-# configuration files
-get_config_name
-
-if [ -z "$IGNORECONFIG" ]; then parse_config
-else verbose "Ignoring configuration files as you requested\n"; fi
-if [ -z "$NOCHECKS" ]; then check_everything; fi
+parse_options "$*"
+check_everything
###
# This is the master-test, it has to be done last.
-if [ -z "$POSSIBLE" ]; then check_possible
-else verbose "Skipping \"possible\" test, using stored value.\n"; fi
-
+check_possible
+
+if [ $POSSIBLE ];
+then
+ verbose "Checks finished - everything seems ok. \n";
+else
+ return 1;
+fi
####
# Builds the enviromental variables list and argument list based
# on the result of the checks
-build_env
-build_args
+build_env()
+build_args()
case "$TASK" in
RECOMMEND)
@@ -614,7 +469,7 @@ case "$TASK" in
echo -e $ARGS
elif [ "x$REC" = "xboth" ]; then
echo -e $ARGS $PLUGINS
- echo -e $ENV
+ echo "$ENV"
fi
if [ $POSSIBLE != "0" ]; then return 1; fi
;;
@@ -623,8 +478,6 @@ case "$TASK" in
start_decorators
;;
*)
- store_config
- start_decorators
start_compiz
;;
esac