From 64469e79828b38689a3d973fe2348b61b3efe423 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Mon, 28 Apr 2003 22:37:17 +0000 Subject: obsolete --- util/bsetbg | 839 ------------------------------------------------------------ 1 file changed, 839 deletions(-) delete mode 100755 util/bsetbg diff --git a/util/bsetbg b/util/bsetbg deleted file mode 100755 index a31bc5b..0000000 --- a/util/bsetbg +++ /dev/null @@ -1,839 +0,0 @@ -#!/bin/sh - -# Copyright (c) 2000 LordZork Industries (lordzork@lordzork.com) -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -# $Id: bsetbg,v 1.5 2003/04/28 14:44:04 fluxgen Exp $ - -# -# Portability notes: -# To guarantee this script works on all platforms that support fluxbox -# please keep the following restrictions in mind: -# -# don't use [ -e file ] use [ -r file ] -# don't use $(), use `` -# don't use ~, use ${HOME} -# don't use id -u, use whoami -# getopts won't work on all platforms, but the config-file can -# compensate for that. -# - - -error_msg() { - case $INFO in - yes|y|1) - info_msg - ;; - esac - - case $1 in - 1) - cat << EOF >&2 - -$NAME: configuration error: $OPTION="$VALUE" -$NAME: please edit $CONFIG and provide the correct variable. -EOF - ;; - 2) - cat << EOF >&2 - -$NAME: error: couldn't execute '$APP'! tried to run fallback option $ARGUMENT -$NAME: but quit because of the following error in $CONFIG: -$NAME: $OPTION=$VALUE -$NAME: please edit $CONFIG and provide the correct variable! -EOF - ;; - 3) - cat << EOF >&2 - -$NAME: error: couldn't find any suitable image applications in the system path! -EOF - error_msg url - ;; - 4) - cat << EOF >&2 - -$NAME: error: invalid option, or non-existent image ($ARGUMENT). -EOF - ;; - 5) - cat << EOF >&2 - -$NAME: error: the image you specified ($IMAGE) could not be found." -EOF - ;; - 6) - cat << EOF >&2 - -$NAME: error: please specify a valid image. -EOF - ;; - 7) - cat << EOF >&2 - -$NAME: error: bsetroot couldn't be found! check your fluxbox installation. -EOF - ;; - 8) - cat << EOF >&2 - -$NAME: error: wrong number of arguments! -$NAME: make sure you enclosed the options for '$APP' in double quotes. -EOF - ;; - nobgapp) - cat << EOF >&2 - -$NAME: error: tried to run '$VALUE' for $ARGUMENT argument, -$NAME: but couldnt find '$APP' in the path! please fix the following -$NAME: line in $CONFIG to point to an existing application: -$NAME: $OPTION=\$VALUE\ -EOF - ;; - nogrep) - cat << EOF >&2 - -$NAME: error: couldn't find grep! -This script needs grep to be in your path in order to function. -You can get GNU grep from ftp://ftp.gnu.org/bin/gnu/grep/ -EOF - ;; - url) - cat << EOF >&2 - -It is suggested that you use qiv, xli (xsetbg), or xv. -You can obtain them at the following locations: - - qiv: http://www.klografx.de/software/qiv.shtml - xli: http://pantransit.reptiles.org/prog/#xli - xv: http://www.trilon.com/xv/downloads.html - -The above URLs are current as of 05/23/2000. -EOF - ;; - esac - exit 1 -} - - -help_msg() { -cat << EOF -$NAME $VERSION: $MORE -options: - - (none) image is set using default values - - -full, -f image is set fullscreen - -tile, -t image is set tiled - -center, -c image is set centered - - -last, -l last used image is set - - -app, -a image is set using with - <'application options'> single-quote-enclosed options and - -center, -c|-tile, -t|-full, -f default fallback option - - -display display to connect to (bsetroot only) - - -mod sets bsetroot modula pattern - -foreground, -fg modula foreground color - -background, -bg modula background color - - -gradient sets bsetroot gradient texture - -from gradient start color - -to gradient end color - - -solid sets bsetroot solid color - - -version, -v outputs $NAME's version number - -info, -i outputs configuration info - -help, -h this message - -usage: -EOF - exit 0 -} - - -info_msg() { - case $ERROR in - [1-3]) - SUMMARY="error: some variables are blank" - ;; - 4) - SUMMARY="no values have been specified" - ;; - 0) - SUMMARY="looks good" - ;; - esac - - case $APP_ERROR in - [1-4]) - SUMMARY="error: some applications couldn't be found!" - ;; - esac - - case `which bsetroot 2>&1` in - */*bsetroot) - BSETROOT=`which bsetroot` - ;; - *) - BSETROOT="(error: not found)" - case $ERROR in - 1-4) - SUMMARY="$SUMMARY, and bsetroot does not seem to be present." - ;; - *) - SUMMARY="$SUMMARY, but bsetroot does not seem to be present." - ;; - esac - ;; - esac -cat << EOF -$NAME $VERSION configuration: - - bsetroot: $BSETROOT - - reading configuration from: $CONFIG - - configuration values: - -EOF - case $FULL_BGAPP_MSG in - *'not found') - echo " fullscreen (ERROR): $FULL_BGAPP_MSG" - ;; - *) - echo " fullscreen (FULL): $FULL_MSG" - ;; - esac - - echo - - case $TILE_BGAPP_MSG in - *'not found') - echo " tiled (ERROR): $TILE_BGAPP_MSG" - ;; - *) - echo " tiled (TILE): $TILE_MSG" - ;; - esac - - echo - - case $CENTER_BGAPP_MSG in - *'not found') - echo " centered (ERROR): $CENTER_BGAPP_MSG" - ;; - *) - echo " centered (CENTER): $CENTER_MSG" - ;; - esac - - echo - - case $DEFAULT_BGAPP_MSG in - *'not found') - echo " default (ERROR): $DEFAULT_BGAPP_MSG" - ;; - *) - echo " default (DEFAULT): $DEFAULT_MSG" - ;; - esac - echo - echo " summary: $SUMMARY" - exit 0 -} - - -find_app() { - APP_PATH=`which $1 2>&1` - case $APP_PATH in - */*$1) - echo "$NAME: checking for $1... $APP_PATH" - cat << EOF >> $TMPFILE -### $app -# FULL="$full" -# TILE="$tile" -# CENTER="$center" -# DEFAULT="$default" - -EOF - FULL=$full - TILE=$tile - CENTER=$center - DEFAULT=$default - APP=$app - ;; - *) - echo "$NAME: checking for $1... not found." - ;; - esac -} - -search_xsri() { - full='xsri --scale-width=100 --scale-width=100' - tile='xsri --tile' - center='xsri --center-x --center-y' - default=$center - find_app xsri -} - -search_display() { - full='display -geometry 800x600 -window root' - tile='display -window root' - center='display -backdrop -window root' - default=$center - find_app display -} - -search_Esetroot() { - full='Esetroot -scale' - tile='Esetroot' - center='Esetroot -c' - default=$center - find_app Esetroot -} - -search_wmsetbg() { - full='wmsetbg -s -S' - tile='wmsetbg -t' - center='wmsetbg -e' - default=$center - find_app wmsetbg -} - -search_xli() { - case `which xsetbg 2>&1` in - */*xsetbg) - full='xsetbg -fillscreen' - tile='xsetbg' - center='xsetbg -center' - default=$center - app='xsetbg (xli)' - find_app xsetbg - ;; - *) - case `which xli 2>&1` in - */*xli) - full='xli -fillscreen -onroot -quiet' - tile='xli -onroot -quiet' - center='xli -center -onroot quiet' - default=$center - app=xli - find_app xli - ;; - esac - ;; - esac -} - -search_qiv() { - full='qiv --root_s' - tile='qiv --root_t' - center='qiv --root' - default=$center - find_app qiv -} - -search_xv() { - full='xv -max -smooth -root -quit' - tile='xv -root -quit' - center='xv -rmode 5 -root -quit' - default=$center - find_app xv -} - - -rm_tmpfiles() { - [ -f $TMPFILE ] && rm -f $TMPFILE -} - - -create_config() { - trap rm_tmpfiles INT QUIT STOP TERM - case `whoami` in root) - if [ ! "$ARGUMENT" = "-r" ]; then - cat << EOF >&2 - -$NAME: Running X as root is a security hazard, and is NOT a good idea! -$NAME: If you insist upon having a ~/.fluxbox/bsetbg for root, run bsetbg with -$NAME: the '-r' flag to force its creation. You have been warned! -$NAME: And you will be warned again and again and again. Don't you get it yet? -$NAME: DON'T DO IT!!! -EOF - exit 1 - fi - ;; - esac - - case $ARGUMENT in - -r) - echo "$NAME: creating configuration for root (BAD IDEA)..." - ;; - *) - echo "$NAME: $CONFIG not found, creating..." - ;; - esac - - rm_tmpfiles - - for app in $IMAGE_APPS; do - search_$app - done - - if [ -z "$FULL" -o -z "$TILE" -o -z "$CENTER" ]; then - rm -f $TMPFILE - unset INFO - error_msg 3 - fi - - if [ ! -d ${HOME}/.fluxbox ]; then - mkdir ${HOME}/.fluxbox - fi - - cat << EOF > ${CONFIG} - -# $CONFIG -# -# Automagically generated with loving care by $NAME $VERSION on `date` -# -# Uncomment the set below that corresponds to your favorite root-image -# application, or mix and match to suit your pleasure. -# -# xli misbehaves under larger screen resolutions when using the -fullscreen -# option. use -fullscreen if your resolution is higher than 1024x768. -# - - -### $APP -FULL="$FULL" -TILE="$TILE" -CENTER="$CENTER" -DEFAULT="$DEFAULT" - -EOF - - grep -v ${APP} ${TMPFILE} >> ${CONFIG} - - rm -f $TMPFILE - - if [ -f $CONFIG ]; then - echo "$NAME: default configuration was created in $CONFIG." - else - echo "ERROR: $CONFIG not found!" - exit 1 - fi -} - -check_config_apps() { - BGAPP=$1 - APP_PATH=`which $BGAPP 2>&1` - case ${APP_PATH} in - */*$BGAPP) - BGAPP_MSG="$APP_PATH" - ;; - *) - BGAPP_MSG="$BGAPP: not found" - APP_ERROR=`expr $APP_ERROR + 1` - ;; - esac -} - - -check_config_vars() { - ERROR=0 - APP_ERROR=0 - - case $FB_ARG in - $FULL) - if [ -z "$FULL" ]; then - FULL_MSG="(no value)" - ERROR=`expr $ERROR + 1` - else - check_config_apps $FULL - FULL_BGAPP_MSG=$BGAPP_MSG - FULL_BGAPP=$BGAPP - FULL_MSG="$FULL" - fi - ;; - $TILE) - if [ -z "$TILE" ]; then - TILE_MSG="(no value)" - ERROR=`expr $ERROR + 1` - else - check_config_apps $TILE - TILE_BGAPP_MSG=$BGAPP_MSG - TILE_BGAPP=$BGAPP - TILE_MSG="$TILE" - fi - ;; - $CENTER) - if [ -z "$CENTER" ]; then - CENTER_MSG="(no value)" - ERROR=`expr $ERROR + 1` - else - check_config_apps $CENTER - CENTER_BGAPP_MSG=$BGAPP_MSG - CENTER_BGAPP=$BGAPP - CENTER_MSG="$CENTER" - fi - ;; - *) - if [ -z "$DEFAULT" ]; then - DEFAULT_MSG="(no value)" - ERROR=`expr $ERROR + 1` - else - check_config_apps $DEFAULT - DEFAULT_BGAPP_MSG=$BGAPP_MSG - DEFAULT_BGAPP=$BGAPP - DEFAULT_MSG="$DEFAULT" - fi - ;; - esac -} - - -final_error_check() { - case $ARGUMENT in - *full|-f|c) - OPTION=FULL - VALUE=$FULL_MSG - FB_ARG=$FULL - case $FULL_BGAPP_MSG in - *'not found') - APP=$FULL_BGAPP - error_msg nobgapp - ;; - esac - ;; - *tile|-t|t) - OPTION=TILE - VALUE=$TILE_MSG - FB_ARG=$TILE - case $TILE_BGAPP_MSG in - *'not found') - APP=$TILE_BGAPP - error_msg nobgapp - ;; - esac - ;; - *center|-c|c) - OPTION=CENTER - VALUE=$CENTER_MSG - FB_ARG=$CENTER - case $CENTER_BGAPP_MSG in - *'not found') - APP=$CENTER_BGAPP - error_msg nobgapp - ;; - esac - ;; - *last|-l|l) - OPTION=DEFAULT - VALUE=$DEFAULT_MSG - FB_ARG=$DEFAULT - ARGUMENT=default - case $DEFAULT_BGAPP_MSG in - *'not found') - APP=$DEFAULT_BGAPP - error_msg nobgapp - ;; - esac - ;; - *) - OPTION=DEFAULT - VALUE=$DEFAULT_MSG - FB_ARG=$DEFAULT - ARGUMENT=default - case $DEFAULT_BGAPP_MSG in - *'not found') - APP=$DEFAULT_BGAPP - error_msg nobgapp - ;; - esac - - if [ ! "$IMAGE_EXISTS" = yes ]; then - error_msg 4; fi - ;; - esac - - case $VALUE in - '(no value)') - if [ -n "$APP" ]; then - error_msg 2 - else - error_msg 1 - fi - ;; - esac -} - - -check_config() { - if [ ! -f $CONFIG ]; then - create_config - fi - - . $CONFIG - check_old_config - final_error_check - check_config_vars -} - - -check_image() { - case "$IMAGE" in - *~/*) - IMAGE="$HOME/`basename $IMAGE`" - ;; - esac - - case $NOARG in - yes|y|1) - NUM=4 - ;; - *) - if [ -n "$IMAGE" ]; then - NUM=5 - else - NUM=6 - fi - case $IMAGE in - $ARGUMENT|'.'|'./') - error_msg 6 - ;; - esac - esac - - if [ ! -r "$IMAGE" ]; then - error_msg $NUM - else - IMAGE_EXISTS=yes - fi -} - - -exec_app() { - case `which $APP 2>&1` in - */*$APP) - check_image - final_error_check - exec $APP $ARGS "$IMAGE" - ;; - *) - check_image - check_config - exec $FB_ARG "$IMAGE" - ;; - esac -} - - -check_bsetroot_args() { - case $1 in - -mod) - ARGS="$1 $2 $3 $4 $5 $6 $7" - ;; - -gradient) - ARGS="$1 $2 $3 $4 $5 $6" - ;; - -solid) - ARGS="$1 $2" - ;; - esac -} - - -exec_bsetroot() { - case `which bsetroot 2>&1` in - */*bsetroot) - exec bsetroot $ARGS - ;; - *) - error_msg 7 - ;; - esac -} - - -check_old_config() { - if [ -f $CONFIG ]; then - if [ -n "$BGAPP" -o -n "$CENTER_ARGS" -o \ - -n "$TILED_ARGS" -o -n "$OTHER_ARGS" -o \ - -n "$DEFAULT_ARGS" ]; then - cat << EOF >&2 -This version of $NAME ($VERSION) no longer uses the old configuration format." -Please update $CONFIG with the new syntax:" - -CENTER="value" -FULL="value" -TILE="value" -DEFAULT="value" - -Look at the sample.config file for details. -EOF - exit 1 - fi - fi -} - - -debug() { -cat << EOF -DEBUG:-------------------------- -config: $CONFIG -full: $FULL -tile: $TILE -center: $CENTER -default: $DEFAULT -error: $ERROR -app error: $APP_ERROR -argument: $ARGUMENT -________________________________ -EOF -} - -IMAGE_APPS="display Esetroot wmsetbg xv xli qiv xsri" -CONFIG="$HOME/.fluxbox/bsetbg" -LASTIMAGEFILE="$HOME/.fluxbox/bsetbg.lastimage" -NAME=`basename $0` -VERSION=1.13 -MORE='(C) 2000 by lordzork industries (http://lordzork.com/)' -PATH=$PATH:/usr/bin:/usr/local/bin:/usr/X11R6/bin:/usr/X11/bin -TMPFILE=$CONFIG.tmp -ARGUMENT=$1 - -which grep > /dev/null 2> /dev/null || error_msg nogrep - -case $1 in - *-full|-f|f) - check_config - IMAGE=$2 - check_image - echo -e "full\n$IMAGE" > $LASTIMAGEFILE - exec $FULL "$IMAGE" - ;; - *-tile|*tiled|-t|t) - check_config - IMAGE=$2 - check_image - echo -e "tile\n$IMAGE" > $LASTIMAGEFILE - exec $TILE "$IMAGE" - ;; - *-center|-c|c) - check_config - IMAGE=$2 - check_image - echo -e "center\n$IMAGE" > $LASTIMAGEFILE - exec $CENTER "$IMAGE" - ;; - *-last|-l|l) - check_config - LASTACTION="`head -n 1 $LASTIMAGEFILE 2> /dev/null`" - IMAGE="`tail -n 1 $LASTIMAGEFILE 2> /dev/null`" && check_image - ACTION=$DEFAULT - case "$LASTACTION" in - full) ACTION=$FULL ;; - tile) ACTION=$TILE ;; - center) ACTION=$CENTER ;; - *) echo "Error: $LASTIMAGEFILE is kaputt" >&2 - exit 1 - ;; - esac - exec $ACTION "$IMAGE" - ;; - *-app|-a|a) - APP=$2 - ARGS="$3" - case $# in - 4) - ARGUMENT=$3 - IMAGE=$4 - exec_app - ;; - 5) - COMMAND=`shift && echo $*` - ARGUMENT=$4 - IMAGE=$5 - exec_app - ;; - *) - error_msg 8 - ;; - esac - ;; - -mod|-gradient|-solid) - check_bsetroot_args $* - exec_bsetroot - ;; - -display) - shift 1 && check_bsetroot_args $* - ARGS="-display $ARGS" - exec_bsetroot - ;; - *-info|-i|i) - INFO=yes - check_config - info_msg - ;; - *-version|-v|v) - cat << EOF - -$NAME version $VERSION -$MORE -EOF - ;; - *-help|-h|h) - help_msg - ;; - -r) - case `whoami` in - root) - if [ -f $CONFIG ]; then - echo 'Error: Config already exists' >&2 - exit 1 - else - create_config - fi - ;; - *) - echo 'Error: -r is for creating a config for root and your are not root' >&2 - exit 1 - esac - ;; - *) - if [ -n "$1" ]; then - NOARG=yes - IMAGE=$1 - check_image - check_config && final_error_check - echo -e "default\n$IMAGE" > $LASTIMAGEFILE - exec $DEFAULT "$1" - else - if [ ! -f $CONFIG ]; then - create_config - fi - help_msg - fi - ;; -esac -- cgit v0.11.2