diff options
author | fluxgen <fluxgen> | 2001-12-11 20:47:02 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2001-12-11 20:47:02 (GMT) |
commit | 18830ac9add80cbd3bf7369307d7e35a519dca9b (patch) | |
tree | 4759a5434a34ba317fe77bbf8b0ed9bb57bb6018 /util/bsetbg | |
parent | 1523b48bff07dead084af3064ad11c79a9b25df0 (diff) | |
download | fluxbox-18830ac9add80cbd3bf7369307d7e35a519dca9b.zip fluxbox-18830ac9add80cbd3bf7369307d7e35a519dca9b.tar.bz2 |
Initial revision
Diffstat (limited to 'util/bsetbg')
-rwxr-xr-x | util/bsetbg | 699 |
1 files changed, 699 insertions, 0 deletions
diff --git a/util/bsetbg b/util/bsetbg new file mode 100755 index 0000000..ccf0fd0 --- /dev/null +++ b/util/bsetbg | |||
@@ -0,0 +1,699 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # Copyright (c) 2000 LordZork Industries (lordzork@lordzork.com) | ||
4 | # | ||
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: | ||
11 | # | ||
12 | # The above copyright notice and this permission notice shall be included in | ||
13 | # all copies or substantial portions of the Software. | ||
14 | # | ||
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. | ||
22 | |||
23 | |||
24 | error_msg() | ||
25 | { | ||
26 | case $INFO in yes|y|1) info_msg; esac | ||
27 | |||
28 | case $1 in | ||
29 | 1) | ||
30 | echo; echo "$NAME: configuration error: $OPTION=\"$VALUE\"" | ||
31 | echo "$NAME: please edit $CONFIG and provide the correct variable." | ||
32 | ;; | ||
33 | 2) | ||
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!" | ||
38 | ;; | ||
39 | 3) | ||
40 | echo; echo "$NAME: error: couldn't find any suitable image applications in the system path!" | ||
41 | echo | ||
42 | error_msg url | ||
43 | ;; | ||
44 | 4) | ||
45 | echo; echo "$NAME: error: invalid option, or non-existent image ($ARGUMENT)." | ||
46 | ;; | ||
47 | 5) | ||
48 | echo; echo "$NAME: error: the image you specified ($IMAGE) could not be found." | ||
49 | ;; | ||
50 | 6) | ||
51 | echo; echo "$NAME: error: please specify a valid image." | ||
52 | ;; | ||
53 | 7) | ||
54 | echo; echo "$NAME: error: bsetroot couldn't be found! check your blackbox installation." | ||
55 | ;; | ||
56 | 8) | ||
57 | echo; echo "$NAME: error: wrong number of arguments!" | ||
58 | echo "$NAME: make sure you enclosed the options for '$APP' in double quotes." | ||
59 | ;; | ||
60 | nobgapp) | ||
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\"" | ||
65 | ;; | ||
66 | nogrep) | ||
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 | ||
70 | ;; | ||
71 | url) | ||
72 | echo "it is suggested that you use qiv, xli (xsetbg), or xv." | ||
73 | echo "you can obtain them at the following locations:" | ||
74 | echo | ||
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" | ||
78 | echo | ||
79 | echo "the above URLs are current as of 05/23/2000." | ||
80 | esac | ||
81 | exit 1 | ||
82 | } | ||
83 | |||
84 | |||
85 | help_msg() | ||
86 | { | ||
87 | echo "$NAME $VERSION: $MORE" | ||
88 | echo "options:" | ||
89 | echo | ||
90 | echo " (none) image is set using default values" | ||
91 | echo | ||
92 | echo " -full, -f image is set fullscreen" | ||
93 | echo " -tile, -t image is set tiled" | ||
94 | echo " -center, -c image is set centered" | ||
95 | echo | ||
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" | ||
99 | echo | ||
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" | ||
104 | echo | ||
105 | echo " -gradient <texture> sets bsetroot gradient texture" | ||
106 | echo " -from <color> gradient start color" | ||
107 | echo " -to <color> gradient end color" | ||
108 | echo | ||
109 | echo " -solid <color> sets bsetroot solid color" | ||
110 | echo | ||
111 | echo " -version, -v outputs $NAME's version number" | ||
112 | echo " -info, -i outputs configuration info" | ||
113 | echo " -help, -h this message" | ||
114 | echo | ||
115 | echo "usage: <options...> <image>" | ||
116 | exit 0 | ||
117 | } | ||
118 | |||
119 | |||
120 | info_msg() | ||
121 | { | ||
122 | case $ERROR in | ||
123 | [1-3]) | ||
124 | SUMMARY="error: some variables are blank" | ||
125 | ;; | ||
126 | 4) | ||
127 | SUMMARY="no values have been specified" | ||
128 | ;; | ||
129 | 0) | ||
130 | SUMMARY="looks good" | ||
131 | esac | ||
132 | |||
133 | case $APP_ERROR in [1-4]) | ||
134 | SUMMARY="error: some applications couldn't be found!" | ||
135 | esac | ||
136 | |||
137 | case `which bsetroot 2>&1` in | ||
138 | */*bsetroot) | ||
139 | BSETROOT=`which bsetroot` | ||
140 | ;; | ||
141 | *) | ||
142 | BSETROOT="(error: not found)" | ||
143 | case $ERROR in | ||
144 | 1-4) | ||
145 | SUMMARY="$SUMMARY, and bsetroot does not seem to be present." | ||
146 | ;; | ||
147 | *) | ||
148 | SUMMARY="$SUMMARY, but bsetroot does not seem to be present." | ||
149 | esac | ||
150 | esac | ||
151 | |||
152 | echo "$NAME $VERSION configuration:" | ||
153 | echo | ||
154 | echo " bsetroot: $BSETROOT" | ||
155 | echo | ||
156 | echo " reading configuration from: $CONFIG" | ||
157 | echo | ||
158 | echo " configuration values:" | ||
159 | echo | ||
160 | case $FULL_BGAPP_MSG in | ||
161 | *"not found") | ||
162 | echo " fullscreen (ERROR): $FULL_BGAPP_MSG" | ||
163 | ;; | ||
164 | *) | ||
165 | echo " fullscreen (FULL): $FULL_MSG" | ||
166 | esac | ||
167 | |||
168 | echo | ||
169 | |||
170 | case $TILE_BGAPP_MSG in | ||
171 | *"not found") | ||
172 | echo " tiled (ERROR): $TILE_BGAPP_MSG" | ||
173 | ;; | ||
174 | *) | ||
175 | echo " tiled (TILE): $TILE_MSG" | ||
176 | esac | ||
177 | |||
178 | echo | ||
179 | |||
180 | case $CENTER_BGAPP_MSG in | ||
181 | *"not found") | ||
182 | echo " centered (ERROR): $CENTER_BGAPP_MSG" | ||
183 | ;; | ||
184 | *) | ||
185 | echo " centered (CENTER): $CENTER_MSG" | ||
186 | esac | ||
187 | |||
188 | echo | ||
189 | |||
190 | case $DEFAULT_BGAPP_MSG in | ||
191 | *"not found") | ||
192 | echo " default (ERROR): $DEFAULT_BGAPP_MSG" | ||
193 | ;; | ||
194 | *) | ||
195 | echo " default (DEFAULT): $DEFAULT_MSG" | ||
196 | esac | ||
197 | echo | ||
198 | echo " summary: $SUMMARY" | ||
199 | exit 0 | ||
200 | } | ||
201 | |||
202 | |||
203 | find_app() | ||
204 | { | ||
205 | case `which $1 2>&1` in | ||
206 | */*$1) | ||
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 | ||
213 | echo >> $TMPFILE | ||
214 | |||
215 | FULL=$full | ||
216 | TILE=$tile | ||
217 | CENTER=$center | ||
218 | DEFAULT=$default | ||
219 | APP=$app | ||
220 | ;; | ||
221 | *) | ||
222 | echo "$NAME: checking for $1... not found." | ||
223 | esac | ||
224 | } | ||
225 | |||
226 | search_display() | ||
227 | { | ||
228 | ### display | ||
229 | full="display -geometry 800x600 -window root" | ||
230 | tile="display -window root" | ||
231 | center="display -backdrop -window root" | ||
232 | default=$center | ||
233 | find_app display | ||
234 | } | ||
235 | |||
236 | search_Esetroot() | ||
237 | { | ||
238 | ### Esetroot | ||
239 | full="Esetroot -scale" | ||
240 | tile="Esetroot" | ||
241 | center="Esetroot -c" | ||
242 | default=$center | ||
243 | find_app Esetroot | ||
244 | } | ||
245 | |||
246 | search_wmsetbg() | ||
247 | { | ||
248 | ### wmsetbg | ||
249 | full="wmsetbg -s -S" | ||
250 | tile="wmsetbg -t" | ||
251 | center="wmsetbg -e" | ||
252 | default=$center | ||
253 | find_app wmsetbg | ||
254 | } | ||
255 | |||
256 | search_xli() | ||
257 | { | ||
258 | ### xli | ||
259 | case `which xsetbg 2>&1` in | ||
260 | */*xsetbg) | ||
261 | full="xsetbg -fillscreen" | ||
262 | tile="xsetbg" | ||
263 | center="xsetbg -center" | ||
264 | default=$center | ||
265 | app="xsetbg (xli)" | ||
266 | find_app xsetbg | ||
267 | ;; | ||
268 | *) | ||
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" | ||
273 | default=$center | ||
274 | app=xli | ||
275 | find_app xli | ||
276 | esac | ||
277 | esac | ||
278 | } | ||
279 | |||
280 | search_qiv() | ||
281 | { | ||
282 | ### qiv | ||
283 | full="qiv --root_s" | ||
284 | tile="qiv --root_t" | ||
285 | center="qiv --root" | ||
286 | default=$center | ||
287 | find_app qiv | ||
288 | } | ||
289 | |||
290 | search_xv() | ||
291 | { | ||
292 | ### xv | ||
293 | full="xv -max -smooth -root -quit" | ||
294 | tile="xv -root -quit" | ||
295 | center="xv -rmode 5 -root -quit" | ||
296 | default=$center | ||
297 | find_app xv | ||
298 | } | ||
299 | |||
300 | |||
301 | rm_tmpfiles() | ||
302 | { | ||
303 | [ -f $TMPFILE ] && rm -f $TMPFILE | ||
304 | [ -f $TMPFILE2 ] && rm -f $TMPFILE2 | ||
305 | } | ||
306 | |||
307 | |||
308 | create_config() | ||
309 | { | ||
310 | trap rm_tmpfiles INT QUIT STOP TERM | ||
311 | case $UID in 0) | ||
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 ~/.bsetbgrc for root, run bsetbg with" | ||
315 | echo "$NAME: the '-r' flag to force its creation. you have been warned!" | ||
316 | exit 1 | ||
317 | fi | ||
318 | esac | ||
319 | |||
320 | case $ARGUMENT in | ||
321 | -r) | ||
322 | echo "$NAME: creating configuration for root (BAD IDEA)..." | ||
323 | ;; | ||
324 | *) | ||
325 | echo "$NAME: $CONFIG not found, creating..." | ||
326 | esac | ||
327 | |||
328 | rm_tmpfiles | ||
329 | |||
330 | for app in $IMAGE_APPS; do | ||
331 | search_$app | ||
332 | done | ||
333 | |||
334 | if [ -z "$FULL" ] || [ -z "TILE" ] || [ -z "$CENTER" ]; then | ||
335 | rm -f $TMPFILE | ||
336 | INFO= && error_msg 3 | ||
337 | fi | ||
338 | |||
339 | echo "# $CONFIG" >> $CONFIG | ||
340 | echo "#" >> $CONFIG | ||
341 | echo "# automagically generated with loving care by $NAME $VERSION on `date`" >> $CONFIG | ||
342 | echo "#" >> $CONFIG | ||
343 | echo "# uncomment the set below that corresponds to your favorite root-image" >> $CONFIG | ||
344 | echo "# application, or mix and match to suit your pleasure." >> $CONFIG | ||
345 | echo "#" >> $CONFIG | ||
346 | echo "# xli misbehaves under larger screen resolutions when using the -fillscreen" >> $CONFIG | ||
347 | echo "# option. use -fullscreen if your resolution is higher than 1024x768." >> $CONFIG | ||
348 | echo "#" >> $CONFIG | ||
349 | echo; echo >> $CONFIG | ||
350 | echo "### $APP" >> $CONFIG | ||
351 | echo "FULL=\"$FULL\"" >> $CONFIG | ||
352 | echo "TILE=\"$TILE\"" >> $CONFIG | ||
353 | echo "CENTER=\"$CENTER\"" >> $CONFIG | ||
354 | echo "DEFAULT=\"$DEFAULT\"" >> $CONFIG | ||
355 | echo >> $CONFIG | ||
356 | |||
357 | cat $TMPFILE | grep -v $APP > $TMPFILE2 | ||
358 | cat "$TMPFILE2" >> $CONFIG | ||
359 | |||
360 | rm -f $TMPFILE $TMPFILE2 | ||
361 | |||
362 | if [ -f $CONFIG ]; then | ||
363 | echo "$NAME: default configuration was created in $CONFIG." | ||
364 | else | ||
365 | echo "ERROR: $CONFIG not found!" && exit 1 | ||
366 | fi | ||
367 | } | ||
368 | |||
369 | check_config_apps() | ||
370 | { | ||
371 | BGAPP=$1 | ||
372 | case `which $1 2>&1` in | ||
373 | */*$1) | ||
374 | BGAPP_MSG="`which $1`" | ||
375 | ;; | ||
376 | *) | ||
377 | BGAPP_MSG="$BGAPP: not found" | ||
378 | APP_ERROR=`expr $APP_ERROR + 1` | ||
379 | esac | ||
380 | } | ||
381 | |||
382 | |||
383 | check_config_vars() | ||
384 | { | ||
385 | ERROR=0 | ||
386 | APP_ERROR=0 | ||
387 | |||
388 | if [ -z "$FULL" ]; then | ||
389 | FULL_MSG="(no value)" && ERROR=`expr $ERROR + 1` | ||
390 | else | ||
391 | check_config_apps $FULL | ||
392 | FULL_BGAPP_MSG=$BGAPP_MSG | ||
393 | FULL_BGAPP=$BGAPP | ||
394 | FULL_MSG="$FULL" | ||
395 | fi | ||
396 | |||
397 | if [ -z "$TILE" ]; then | ||
398 | TILE_MSG="(no value)" && ERROR=`expr $ERROR + 1` | ||
399 | else | ||
400 | check_config_apps $TILE | ||
401 | TILE_BGAPP_MSG=$BGAPP_MSG | ||
402 | TILE_BGAPP=$BGAPP | ||
403 | TILE_MSG="$TILE" | ||
404 | fi | ||
405 | |||
406 | if [ -z "$CENTER" ]; then | ||
407 | CENTER_MSG="(no value)" && ERROR=`expr $ERROR + 1` | ||
408 | else | ||
409 | check_config_apps $CENTER | ||
410 | CENTER_BGAPP_MSG=$BGAPP_MSG | ||
411 | CENTER_BGAPP=$BGAPP | ||
412 | CENTER_MSG="$CENTER" | ||
413 | fi | ||
414 | |||
415 | if [ -z "$DEFAULT" ]; then | ||
416 | DEFAULT_MSG="(no value)" && ERROR=`expr $ERROR + 1` | ||
417 | else | ||
418 | check_config_apps $DEFAULT | ||
419 | DEFAULT_BGAPP_MSG=$BGAPP_MSG | ||
420 | DEFAULT_BGAPP=$BGAPP | ||
421 | DEFAULT_MSG="$DEFAULT" | ||
422 | fi | ||
423 | } | ||
424 | |||
425 | |||
426 | final_error_check() | ||
427 | { | ||
428 | case $ARGUMENT in | ||
429 | *full|-f|c) | ||
430 | OPTION=FULL | ||
431 | VALUE=$FULL_MSG | ||
432 | FB_ARG=$FULL | ||
433 | case $FULL_BGAPP_MSG in *"not found") | ||
434 | APP=$FULL_BGAPP | ||
435 | error_msg nobgapp | ||
436 | esac | ||
437 | ;; | ||
438 | *tile|-t|t) | ||
439 | OPTION=TILE | ||
440 | VALUE=$TILE_MSG | ||
441 | FB_ARG=$TILE | ||
442 | case $TILE_BGAPP_MSG in *"not found") | ||
443 | APP=$TILE_BGAPP | ||
444 | error_msg nobgapp | ||
445 | esac | ||
446 | ;; | ||
447 | *center|-c|c) | ||
448 | OPTION=CENTER | ||
449 | VALUE=$CENTER_MSG | ||
450 | FB_ARG=$CENTER | ||
451 | case $CENTER_BGAPP_MSG in *"not found") | ||
452 | APP=$CENTER_BGAPP | ||
453 | error_msg nobgapp | ||
454 | esac | ||
455 | ;; | ||
456 | *) | ||
457 | OPTION=DEFAULT | ||
458 | VALUE=$DEFAULT_MSG | ||
459 | FB_ARG=$DEFAULT | ||
460 | ARGUMENT=default | ||
461 | case $DEFAULT_BGAPP_MSG in *"not found") | ||
462 | APP=$DEFAULT_BGAPP | ||
463 | error_msg nobgapp | ||
464 | esac | ||
465 | |||
466 | if [ "$IMAGE_EXISTS" != yes ]; then | ||
467 | error_msg 4; fi | ||
468 | esac | ||
469 | |||
470 | case $VALUE in "(no value)") | ||
471 | if [ -n "$APP" ]; then | ||
472 | error_msg 2 | ||
473 | else | ||
474 | error_msg 1 | ||
475 | fi | ||
476 | esac | ||
477 | } | ||
478 | |||
479 | |||
480 | check_config() | ||
481 | { | ||
482 | if [ ! -f $CONFIG ]; then | ||
483 | create_config | ||
484 | fi | ||
485 | |||
486 | check_old_config | ||
487 | . $CONFIG | ||
488 | check_config_vars | ||
489 | final_error_check | ||
490 | } | ||
491 | |||
492 | |||
493 | check_image() | ||
494 | { | ||
495 | case "$IMAGE" in | ||
496 | *~/*) | ||
497 | IMAGE="$HOME/`basename $IMAGE`" | ||
498 | esac | ||
499 | |||
500 | case $NOARG in | ||
501 | yes|y|1) | ||
502 | NUM=4 | ||
503 | ;; | ||
504 | *) | ||
505 | if [ -n "$IMAGE" ]; then | ||
506 | NUM=5 | ||
507 | else | ||
508 | NUM=6 | ||
509 | fi | ||
510 | case $IMAGE in $ARGUMENT|"."|"./") | ||
511 | error_msg 6 | ||
512 | esac | ||
513 | esac | ||
514 | |||
515 | if [ ! -e "$IMAGE" ]; then | ||
516 | error_msg $NUM | ||
517 | else | ||
518 | IMAGE_EXISTS=yes | ||
519 | fi | ||
520 | } | ||
521 | |||
522 | |||
523 | exec_app() | ||
524 | { | ||
525 | case `which $APP 2>&1` in | ||
526 | */*$APP) | ||
527 | check_image | ||
528 | final_error_check | ||
529 | exec $APP $ARGS "$IMAGE" | ||
530 | ;; | ||
531 | *) | ||
532 | check_image | ||
533 | check_config | ||
534 | exec $FB_ARG "$IMAGE" | ||
535 | esac | ||
536 | } | ||
537 | |||
538 | |||
539 | check_bsetroot_args() | ||
540 | { | ||
541 | case $1 in | ||
542 | -mod) | ||
543 | ARGS="$1 $2 $3 $4 $5 $6 $7" | ||
544 | ;; | ||
545 | -gradient) | ||
546 | ARGS="$1 $2 $3 $4 $5 $6" | ||
547 | ;; | ||
548 | -solid) | ||
549 | ARGS="$1 $2" | ||
550 | esac | ||
551 | } | ||
552 | |||
553 | |||
554 | exec_bsetroot() | ||
555 | { | ||
556 | case `which bsetroot 2>&1` in | ||
557 | */*bsetroot) | ||
558 | exec bsetroot $ARGS | ||
559 | ;; | ||
560 | *) | ||
561 | error_msg 7 | ||
562 | esac | ||
563 | } | ||
564 | |||
565 | |||
566 | check_old_config() | ||
567 | { | ||
568 | if [ -f $CONFIG ]; then | ||
569 | . $CONFIG | ||
570 | if [ -n "$BGAPP" ] || [ -n "$CENTER_ARGS" ] || \ | ||
571 | [ -n "$TILED_ARGS" ] || [ -n "$OTHER_ARGS" ] || \ | ||
572 | [ -n "$DEFAULT_ARGS" ]; then | ||
573 | echo " this version of $NAME ($VERSION) no longer uses the old configuration format." | ||
574 | echo " please update $CONFIG with the new syntax:" | ||
575 | echo | ||
576 | echo " CENTER=\"value\"" | ||
577 | echo " FULL=\"value\"" | ||
578 | echo " TILE=\"value\"" | ||
579 | echo " DEFAULT=\"value\"" | ||
580 | echo | ||
581 | echo " see the sample.config file for details." | ||
582 | exit 0 | ||
583 | fi | ||
584 | fi | ||
585 | } | ||
586 | |||
587 | |||
588 | debug() | ||
589 | { | ||
590 | echo "DEBUG:--------------------------" | ||
591 | echo "config: $CONFIG" | ||
592 | echo "full: $FULL" | ||
593 | echo "tile: $TILE" | ||
594 | echo "center: $CENTER" | ||
595 | echo "default: $DEFAULT" | ||
596 | echo "error: $ERROR" | ||
597 | echo "app error: $APP_ERROR" | ||
598 | echo "argument: $ARGUMENT" | ||
599 | echo "________________________________" | ||
600 | echo | ||
601 | } | ||
602 | |||
603 | IMAGE_APPS="display Esetroot wmsetbg xv xli qiv" | ||
604 | CONFIG="$HOME/.bsetbgrc" | ||
605 | NAME=bsetbg | ||
606 | VERSION=1.12 | ||
607 | MORE="(C) 2000 by lordzork industries (http://lordzork.com/)" | ||
608 | PATH=$PATH:/usr/bin:/usr/local/bin:/usr/X11R6/bin:/usr/X11/bin | ||
609 | TMPFILE=/tmp/bsetbg.1 | ||
610 | TMPFILE2=/tmp/bsetbg.2 | ||
611 | ARGUMENT=$1 | ||
612 | |||
613 | |||
614 | case `which grep 2>&1` in */*grep) : ;; | ||
615 | *) | ||
616 | error_msg nogrep | ||
617 | esac | ||
618 | |||
619 | case $1 in | ||
620 | *-full|-f|f) | ||
621 | check_config | ||
622 | IMAGE=$2 && check_image | ||
623 | exec $FULL "$IMAGE" | ||
624 | ;; | ||
625 | *-tile|*tiled|-t|t) | ||
626 | check_config | ||
627 | IMAGE=$2 && check_image | ||
628 | exec $TILE "$IMAGE" | ||
629 | ;; | ||
630 | *-center|-c|c) | ||
631 | check_config | ||
632 | IMAGE=$2 && check_image | ||
633 | exec $CENTER "$IMAGE" | ||
634 | ;; | ||
635 | *-app|-a|a) | ||
636 | APP=$2 | ||
637 | ARGS="$3" | ||
638 | case $# in | ||
639 | 4) | ||
640 | ARGMENT=$3 | ||
641 | IMAGE=$4 | ||
642 | exec_app | ||
643 | ;; | ||
644 | 5) | ||
645 | COMMAND=`shift 1 && echo $*` | ||
646 | ARGUMENT=$4 | ||
647 | IMAGE=$5 | ||
648 | exec_app | ||
649 | ;; | ||
650 | *) | ||
651 | error_msg 8 | ||
652 | esac | ||
653 | ;; | ||
654 | -mod|-gradient|-solid) | ||
655 | check_bsetroot_args $* | ||
656 | exec_bsetroot | ||
657 | ;; | ||
658 | -display) | ||
659 | shift 1 && check_bsetroot_args $* | ||
660 | ARGS="-display $ARGS" | ||
661 | exec_bsetroot | ||
662 | ;; | ||
663 | *-info|-i|i) | ||
664 | INFO=yes | ||
665 | check_config | ||
666 | info_msg | ||
667 | ;; | ||
668 | *-version|-v|v) | ||
669 | echo; echo " $NAME version $VERSION"; echo " $MORE"; exit 0 | ||
670 | ;; | ||
671 | *-help|-h|h) | ||
672 | help_msg | ||
673 | ;; | ||
674 | -r) | ||
675 | case $UID in | ||
676 | 0) | ||
677 | if [ -f $CONFIG ]; then | ||
678 | exit 1 | ||
679 | else | ||
680 | create_config | ||
681 | fi | ||
682 | ;; | ||
683 | *) | ||
684 | exit 1 | ||
685 | esac | ||
686 | ;; | ||
687 | *) | ||
688 | if [ -n "$1" ]; then | ||
689 | NOARG=yes | ||
690 | IMAGE=$1 && check_image | ||
691 | check_config && final_error_check | ||
692 | exec $DEFAULT "$1" | ||
693 | else | ||
694 | if [ ! -f $CONFIG ]; then | ||
695 | create_config && exit 0 | ||
696 | fi | ||
697 | help_msg | ||
698 | fi | ||
699 | esac \ No newline at end of file | ||