3
# Copyright (c) 2000 LordZork Industries (lordzork@lordzork.com)
5
# Permission is hereby granted, free of charge, to any person obtaining a
6
# copy of this software and associated documentation files (the "Software"),
7
# to deal in the Software without restriction, including without limitation
8
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
# and/or sell copies of the Software, and to permit persons to whom the
10
# Software is furnished to do so, subject to the following conditions:
12
# The above copyright notice and this permission notice shall be included in
13
# all copies or substantial portions of the Software.
15
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21
# DEALINGS IN THE SOFTWARE.
26
case $INFO in yes|y|1) info_msg; esac
30
echo; echo "$NAME: configuration error: $OPTION=\"$VALUE\""
31
echo "$NAME: please edit $CONFIG and provide the correct variable."
34
echo; echo "$NAME: error: couldn't execute '$APP'! tried to run fallback option $ARGUMENT"
35
echo "$NAME: but quit because of the following error in $CONFIG:"
36
echo "$NAME: $OPTION= $VALUE"
37
echo "$NAME: please edit $CONFIG and provide the correct variable!"
40
echo; echo "$NAME: error: couldn't find any suitable image applications in the system path!"
45
echo; echo "$NAME: error: invalid option, or non-existent image ($ARGUMENT)."
48
echo; echo "$NAME: error: the image you specified ($IMAGE) could not be found."
51
echo; echo "$NAME: error: please specify a valid image."
54
echo; echo "$NAME: error: bsetroot couldn't be found! check your blackbox installation."
57
echo; echo "$NAME: error: wrong number of arguments!"
58
echo "$NAME: make sure you enclosed the options for '$APP' in double quotes."
61
echo; echo "$NAME: error: tried to run '$VALUE' for $ARGUMENT argument,"
62
echo "$NAME: but couldnt find '$APP' in the path! please fix the following"
63
echo "$NAME: line in $CONFIG to point to an existing application:"
64
echo "$NAME: $OPTION=\"$VALUE\""
67
echo "$NAME: error: couldn't find grep!"
68
echo "this script needs grep to be in your path in order to function."
69
echo "you can get GNU grep from ftp://ftp.gnu.org/bin/gnu/grep/" && exit 1
72
echo "it is suggested that you use qiv, xli (xsetbg), or xv."
73
echo "you can obtain them at the following locations:"
75
echo " qiv: http://www.klografx.de/software/qiv.shtml"
76
echo " xli: http://pantransit.reptiles.org/prog/#xli"
77
echo " xv: http://www.trilon.com/xv/downloads.html"
79
echo "the above URLs are current as of 05/23/2000."
87
echo "$NAME $VERSION: $MORE"
90
echo " (none) image is set using default values"
92
echo " -full, -f image is set fullscreen"
93
echo " -tile, -t image is set tiled"
94
echo " -center, -c image is set centered"
96
echo " -app, -a <application> image is set using <application> with"
97
echo " <"'"application options"'"> quote-enclosed \"options\" and"
98
echo " -center, -c|-tile, -t|-full, -f default fallback option"
100
echo " -display <string> display to connect to (bsetroot only)"
101
echo " -mod <x> <y> sets bsetroot modula pattern"
102
echo " -foreground, -fg <color> modula foreground color"
103
echo " -background, -bg <color> modula background color"
105
echo " -gradient <texture> sets bsetroot gradient texture"
106
echo " -from <color> gradient start color"
107
echo " -to <color> gradient end color"
109
echo " -solid <color> sets bsetroot solid color"
111
echo " -version, -v outputs $NAME's version number"
112
echo " -info, -i outputs configuration info"
113
echo " -help, -h this message"
115
echo "usage: <options...> <image>"
124
SUMMARY="error: some variables are blank"
127
SUMMARY="no values have been specified"
133
case $APP_ERROR in [1-4])
134
SUMMARY="error: some applications couldn't be found!"
137
case `which bsetroot 2>&1` in
139
BSETROOT=`which bsetroot`
142
BSETROOT="(error: not found)"
145
SUMMARY="$SUMMARY, and bsetroot does not seem to be present."
148
SUMMARY="$SUMMARY, but bsetroot does not seem to be present."
152
echo "$NAME $VERSION configuration:"
154
echo " bsetroot: $BSETROOT"
156
echo " reading configuration from: $CONFIG"
158
echo " configuration values:"
160
case $FULL_BGAPP_MSG in
162
echo " fullscreen (ERROR): $FULL_BGAPP_MSG"
165
echo " fullscreen (FULL): $FULL_MSG"
170
case $TILE_BGAPP_MSG in
172
echo " tiled (ERROR): $TILE_BGAPP_MSG"
175
echo " tiled (TILE): $TILE_MSG"
180
case $CENTER_BGAPP_MSG in
182
echo " centered (ERROR): $CENTER_BGAPP_MSG"
185
echo " centered (CENTER): $CENTER_MSG"
190
case $DEFAULT_BGAPP_MSG in
192
echo " default (ERROR): $DEFAULT_BGAPP_MSG"
195
echo " default (DEFAULT): $DEFAULT_MSG"
198
echo " summary: $SUMMARY"
205
case `which $1 2>&1` in
207
echo "$NAME: checking for $1... `which $1`"
208
echo "### $app" >> $TMPFILE
209
echo "# FULL=\"$full\"" >> $TMPFILE
210
echo "# TILE=\"$tile\"" >> $TMPFILE
211
echo "# CENTER=\"$center\"" >> $TMPFILE
212
echo "# DEFAULT=\"$default\"" >> $TMPFILE
222
echo "$NAME: checking for $1... not found."
229
full="display -geometry 800x600 -window root"
230
tile="display -window root"
231
center="display -backdrop -window root"
239
full="Esetroot -scale"
259
case `which xsetbg 2>&1` in
261
full="xsetbg -fillscreen"
263
center="xsetbg -center"
269
case `which xli 2>&1` in */*xli)
270
full="xli -fillscreen -onroot -quiet"
271
tile="xli -onroot -quiet"
272
center="xli -center -onroot quiet"
293
full="xv -max -smooth -root -quit"
294
tile="xv -root -quit"
295
center="xv -rmode 5 -root -quit"
303
[ -f $TMPFILE ] && rm -f $TMPFILE
304
[ -f $TMPFILE2 ] && rm -f $TMPFILE2
310
trap rm_tmpfiles INT QUIT STOP TERM
312
if [ "$ARGUMENT" != "-r" ]; then
313
echo "$NAME: running X as root is a security hazard, and is NOT a good idea!"
314
echo "$NAME: if you insist upon having a ~/.fluxbox/bsetbg for root, run bsetbg with"
315
echo "$NAME: the '-r' flag to force its creation. you have been warned!"
322
echo "$NAME: creating configuration for root (BAD IDEA)..."
325
echo "$NAME: $CONFIG not found, creating..."
330
for app in $IMAGE_APPS; do
334
if [ -z "$FULL" ] || [ -z "TILE" ] || [ -z "$CENTER" ]; then
339
if [ ! -d ~/.fluxbox ]; then
343
echo "# $CONFIG" >> $CONFIG
345
echo "# automagically generated with loving care by $NAME $VERSION on `date`" >> $CONFIG
347
echo "# uncomment the set below that corresponds to your favorite root-image" >> $CONFIG
348
echo "# application, or mix and match to suit your pleasure." >> $CONFIG
350
echo "# xli misbehaves under larger screen resolutions when using the -fillscreen" >> $CONFIG
351
echo "# option. use -fullscreen if your resolution is higher than 1024x768." >> $CONFIG
353
echo; echo >> $CONFIG
354
echo "### $APP" >> $CONFIG
355
echo "FULL=\"$FULL\"" >> $CONFIG
356
echo "TILE=\"$TILE\"" >> $CONFIG
357
echo "CENTER=\"$CENTER\"" >> $CONFIG
358
echo "DEFAULT=\"$DEFAULT\"" >> $CONFIG
361
cat $TMPFILE | grep -v $APP > $TMPFILE2
362
cat "$TMPFILE2" >> $CONFIG
364
rm -f $TMPFILE $TMPFILE2
366
if [ -f $CONFIG ]; then
367
echo "$NAME: default configuration was created in $CONFIG."
369
echo "ERROR: $CONFIG not found!" && exit 1
376
case `which $1 2>&1` in
378
BGAPP_MSG="`which $1`"
381
BGAPP_MSG="$BGAPP: not found"
382
APP_ERROR=`expr $APP_ERROR + 1`
392
if [ -z "$FULL" ]; then
393
FULL_MSG="(no value)" && ERROR=`expr $ERROR + 1`
395
check_config_apps $FULL
396
FULL_BGAPP_MSG=$BGAPP_MSG
401
if [ -z "$TILE" ]; then
402
TILE_MSG="(no value)" && ERROR=`expr $ERROR + 1`
404
check_config_apps $TILE
405
TILE_BGAPP_MSG=$BGAPP_MSG
410
if [ -z "$CENTER" ]; then
411
CENTER_MSG="(no value)" && ERROR=`expr $ERROR + 1`
413
check_config_apps $CENTER
414
CENTER_BGAPP_MSG=$BGAPP_MSG
419
if [ -z "$DEFAULT" ]; then
420
DEFAULT_MSG="(no value)" && ERROR=`expr $ERROR + 1`
422
check_config_apps $DEFAULT
423
DEFAULT_BGAPP_MSG=$BGAPP_MSG
425
DEFAULT_MSG="$DEFAULT"
437
case $FULL_BGAPP_MSG in *"not found")
446
case $TILE_BGAPP_MSG in *"not found")
455
case $CENTER_BGAPP_MSG in *"not found")
465
case $DEFAULT_BGAPP_MSG in *"not found")
470
if [ "$IMAGE_EXISTS" != yes ]; then
474
case $VALUE in "(no value)")
475
if [ -n "$APP" ]; then
486
if [ ! -f $CONFIG ]; then
501
IMAGE="$HOME/`basename $IMAGE`"
509
if [ -n "$IMAGE" ]; then
514
case $IMAGE in $ARGUMENT|"."|"./")
519
if [ ! -e "$IMAGE" ]; then
529
case `which $APP 2>&1` in
533
exec $APP $ARGS "$IMAGE"
538
exec $FB_ARG "$IMAGE"
543
check_bsetroot_args()
547
ARGS="$1 $2 $3 $4 $5 $6 $7"
550
ARGS="$1 $2 $3 $4 $5 $6"
560
case `which bsetroot 2>&1` in
572
if [ -f $CONFIG ]; then
574
if [ -n "$BGAPP" ] || [ -n "$CENTER_ARGS" ] || \
575
[ -n "$TILED_ARGS" ] || [ -n "$OTHER_ARGS" ] || \
576
[ -n "$DEFAULT_ARGS" ]; then
577
echo " this version of $NAME ($VERSION) no longer uses the old configuration format."
578
echo " please update $CONFIG with the new syntax:"
580
echo " CENTER=\"value\""
581
echo " FULL=\"value\""
582
echo " TILE=\"value\""
583
echo " DEFAULT=\"value\""
585
echo " see the sample.config file for details."
594
echo "DEBUG:--------------------------"
595
echo "config: $CONFIG"
598
echo "center: $CENTER"
599
echo "default: $DEFAULT"
601
echo "app error: $APP_ERROR"
602
echo "argument: $ARGUMENT"
603
echo "________________________________"
607
IMAGE_APPS="display Esetroot wmsetbg xv xli qiv"
608
CONFIG="$HOME/.fluxbox/bsetbg"
611
MORE="(C) 2000 by lordzork industries (http://lordzork.com/)"
612
PATH=$PATH:/usr/bin:/usr/local/bin:/usr/X11R6/bin:/usr/X11/bin
613
TMPFILE=/tmp/bsetbg.1
614
TMPFILE2=/tmp/bsetbg.2
618
case `which grep 2>&1` in */*grep) : ;;
626
IMAGE=$2 && check_image
631
IMAGE=$2 && check_image
636
IMAGE=$2 && check_image
637
exec $CENTER "$IMAGE"
649
COMMAND=`shift 1 && echo $*`
658
-mod|-gradient|-solid)
659
check_bsetroot_args $*
663
shift 1 && check_bsetroot_args $*
664
ARGS="-display $ARGS"
673
echo; echo " $NAME version $VERSION"; echo " $MORE"; exit 0
681
if [ -f $CONFIG ]; then
694
IMAGE=$1 && check_image
695
check_config && final_error_check
698
if [ ! -f $CONFIG ]; then
699
create_config && exit 0