aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-04-28 22:37:17 (GMT)
committerfluxgen <fluxgen>2003-04-28 22:37:17 (GMT)
commit64469e79828b38689a3d973fe2348b61b3efe423 (patch)
tree38cfa9c13a44526ccee906179da1f2d69cef5989 /util
parent157673be297d3e950adff0070b359536e266d18d (diff)
downloadfluxbox-64469e79828b38689a3d973fe2348b61b3efe423.zip
fluxbox-64469e79828b38689a3d973fe2348b61b3efe423.tar.bz2
obsolete
Diffstat (limited to 'util')
-rwxr-xr-xutil/bsetbg839
1 files changed, 0 insertions, 839 deletions
diff --git a/util/bsetbg b/util/bsetbg
deleted file mode 100755
index a31bc5b..0000000
--- a/util/bsetbg
+++ /dev/null
@@ -1,839 +0,0 @@
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
6# a copy of this software and associated documentation files (the
7# "Software"), to deal in the Software without restriction, including
8# without limitation the rights to use, copy, modify, merge, publish,
9# distribute, sublicense, and/or sell copies of the Software, and to
10# permit persons to whom the Software is furnished to do so, subject to
11# the following conditions:
12#
13# The above copyright notice and this permission notice shall be
14# included in all copies or substantial portions of the Software.
15#
16# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
24# $Id: bsetbg,v 1.5 2003/04/28 14:44:04 fluxgen Exp $
25
26#
27# Portability notes:
28# To guarantee this script works on all platforms that support fluxbox
29# please keep the following restrictions in mind:
30#
31# don't use [ -e file ] use [ -r file ]
32# don't use $(), use ``
33# don't use ~, use ${HOME}
34# don't use id -u, use whoami
35# getopts won't work on all platforms, but the config-file can
36# compensate for that.
37#
38
39
40error_msg() {
41 case $INFO in
42 yes|y|1)
43 info_msg
44 ;;
45 esac
46
47 case $1 in
48 1)
49 cat << EOF >&2
50
51$NAME: configuration error: $OPTION="$VALUE"
52$NAME: please edit $CONFIG and provide the correct variable.
53EOF
54 ;;
55 2)
56 cat << EOF >&2
57
58$NAME: error: couldn't execute '$APP'! tried to run fallback option $ARGUMENT
59$NAME: but quit because of the following error in $CONFIG:
60$NAME: $OPTION=$VALUE
61$NAME: please edit $CONFIG and provide the correct variable!
62EOF
63 ;;
64 3)
65 cat << EOF >&2
66
67$NAME: error: couldn't find any suitable image applications in the system path!
68EOF
69 error_msg url
70 ;;
71 4)
72 cat << EOF >&2
73
74$NAME: error: invalid option, or non-existent image ($ARGUMENT).
75EOF
76 ;;
77 5)
78 cat << EOF >&2
79
80$NAME: error: the image you specified ($IMAGE) could not be found."
81EOF
82 ;;
83 6)
84 cat << EOF >&2
85
86$NAME: error: please specify a valid image.
87EOF
88 ;;
89 7)
90 cat << EOF >&2
91
92$NAME: error: bsetroot couldn't be found! check your fluxbox installation.
93EOF
94 ;;
95 8)
96 cat << EOF >&2
97
98$NAME: error: wrong number of arguments!
99$NAME: make sure you enclosed the options for '$APP' in double quotes.
100EOF
101 ;;
102 nobgapp)
103 cat << EOF >&2
104
105$NAME: error: tried to run '$VALUE' for $ARGUMENT argument,
106$NAME: but couldnt find '$APP' in the path! please fix the following
107$NAME: line in $CONFIG to point to an existing application:
108$NAME: $OPTION=\$VALUE\
109EOF
110 ;;
111 nogrep)
112 cat << EOF >&2
113
114$NAME: error: couldn't find grep!
115This script needs grep to be in your path in order to function.
116You can get GNU grep from ftp://ftp.gnu.org/bin/gnu/grep/
117EOF
118 ;;
119 url)
120 cat << EOF >&2
121
122It is suggested that you use qiv, xli (xsetbg), or xv.
123You can obtain them at the following locations:
124
125 qiv: http://www.klografx.de/software/qiv.shtml
126 xli: http://pantransit.reptiles.org/prog/#xli
127 xv: http://www.trilon.com/xv/downloads.html
128
129The above URLs are current as of 05/23/2000.
130EOF
131 ;;
132 esac
133 exit 1
134}
135
136
137help_msg() {
138cat << EOF
139$NAME $VERSION: $MORE
140options:
141
142 (none) image is set using default values
143
144 -full, -f image is set fullscreen
145 -tile, -t image is set tiled
146 -center, -c image is set centered
147
148 -last, -l last used image is set
149
150 -app, -a <application> image is set using <application> with
151 <'application options'> single-quote-enclosed options and
152 -center, -c|-tile, -t|-full, -f default fallback option
153
154 -display <string> display to connect to (bsetroot only)
155
156 -mod <x> <y> sets bsetroot modula pattern
157 -foreground, -fg <color> modula foreground color
158 -background, -bg <color> modula background color
159
160 -gradient <texture> sets bsetroot gradient texture
161 -from <color> gradient start color
162 -to <color> gradient end color
163
164 -solid <color> sets bsetroot solid color
165
166 -version, -v outputs $NAME's version number
167 -info, -i outputs configuration info
168 -help, -h this message
169
170usage: <options...> <image>
171EOF
172 exit 0
173}
174
175
176info_msg() {
177 case $ERROR in
178 [1-3])
179 SUMMARY="error: some variables are blank"
180 ;;
181 4)
182 SUMMARY="no values have been specified"
183 ;;
184 0)
185 SUMMARY="looks good"
186 ;;
187 esac
188
189 case $APP_ERROR in
190 [1-4])
191 SUMMARY="error: some applications couldn't be found!"
192 ;;
193 esac
194
195 case `which bsetroot 2>&1` in
196 */*bsetroot)
197 BSETROOT=`which bsetroot`
198 ;;
199 *)
200 BSETROOT="(error: not found)"
201 case $ERROR in
202 1-4)
203 SUMMARY="$SUMMARY, and bsetroot does not seem to be present."
204 ;;
205 *)
206 SUMMARY="$SUMMARY, but bsetroot does not seem to be present."
207 ;;
208 esac
209 ;;
210 esac
211cat << EOF
212$NAME $VERSION configuration:
213
214 bsetroot: $BSETROOT
215
216 reading configuration from: $CONFIG
217
218 configuration values:
219
220EOF
221 case $FULL_BGAPP_MSG in
222 *'not found')
223 echo " fullscreen (ERROR): $FULL_BGAPP_MSG"
224 ;;
225 *)
226 echo " fullscreen (FULL): $FULL_MSG"
227 ;;
228 esac
229
230 echo
231
232 case $TILE_BGAPP_MSG in
233 *'not found')
234 echo " tiled (ERROR): $TILE_BGAPP_MSG"
235 ;;
236 *)
237 echo " tiled (TILE): $TILE_MSG"
238 ;;
239 esac
240
241 echo
242
243 case $CENTER_BGAPP_MSG in
244 *'not found')
245 echo " centered (ERROR): $CENTER_BGAPP_MSG"
246 ;;
247 *)
248 echo " centered (CENTER): $CENTER_MSG"
249 ;;
250 esac
251
252 echo
253
254 case $DEFAULT_BGAPP_MSG in
255 *'not found')
256 echo " default (ERROR): $DEFAULT_BGAPP_MSG"
257 ;;
258 *)
259 echo " default (DEFAULT): $DEFAULT_MSG"
260 ;;
261 esac
262 echo
263 echo " summary: $SUMMARY"
264 exit 0
265}
266
267
268find_app() {
269 APP_PATH=`which $1 2>&1`
270 case $APP_PATH in
271 */*$1)
272 echo "$NAME: checking for $1... $APP_PATH"
273 cat << EOF >> $TMPFILE
274### $app
275# FULL="$full"
276# TILE="$tile"
277# CENTER="$center"
278# DEFAULT="$default"
279
280EOF
281 FULL=$full
282 TILE=$tile
283 CENTER=$center
284 DEFAULT=$default
285 APP=$app
286 ;;
287 *)
288 echo "$NAME: checking for $1... not found."
289 ;;
290 esac
291}
292
293search_xsri() {
294 full='xsri --scale-width=100 --scale-width=100'
295 tile='xsri --tile'
296 center='xsri --center-x --center-y'
297 default=$center
298 find_app xsri
299}
300
301search_display() {
302 full='display -geometry 800x600 -window root'
303 tile='display -window root'
304 center='display -backdrop -window root'
305 default=$center
306 find_app display
307}
308
309search_Esetroot() {
310 full='Esetroot -scale'
311 tile='Esetroot'
312 center='Esetroot -c'
313 default=$center
314 find_app Esetroot
315}
316
317search_wmsetbg() {
318 full='wmsetbg -s -S'
319 tile='wmsetbg -t'
320 center='wmsetbg -e'
321 default=$center
322 find_app wmsetbg
323}
324
325search_xli() {
326 case `which xsetbg 2>&1` in
327 */*xsetbg)
328 full='xsetbg -fillscreen'
329 tile='xsetbg'
330 center='xsetbg -center'
331 default=$center
332 app='xsetbg (xli)'
333 find_app xsetbg
334 ;;
335 *)
336 case `which xli 2>&1` in
337 */*xli)
338 full='xli -fillscreen -onroot -quiet'
339 tile='xli -onroot -quiet'
340 center='xli -center -onroot quiet'
341 default=$center
342 app=xli
343 find_app xli
344 ;;
345 esac
346 ;;
347 esac
348}
349
350search_qiv() {
351 full='qiv --root_s'
352 tile='qiv --root_t'
353 center='qiv --root'
354 default=$center
355 find_app qiv
356}
357
358search_xv() {
359 full='xv -max -smooth -root -quit'
360 tile='xv -root -quit'
361 center='xv -rmode 5 -root -quit'
362 default=$center
363 find_app xv
364}
365
366
367rm_tmpfiles() {
368 [ -f $TMPFILE ] && rm -f $TMPFILE
369}
370
371
372create_config() {
373 trap rm_tmpfiles INT QUIT STOP TERM
374 case `whoami` in root)
375 if [ ! "$ARGUMENT" = "-r" ]; then
376 cat << EOF >&2
377
378$NAME: Running X as root is a security hazard, and is NOT a good idea!
379$NAME: If you insist upon having a ~/.fluxbox/bsetbg for root, run bsetbg with
380$NAME: the '-r' flag to force its creation. You have been warned!
381$NAME: And you will be warned again and again and again. Don't you get it yet?
382$NAME: DON'T DO IT!!!
383EOF
384 exit 1
385 fi
386 ;;
387 esac
388
389 case $ARGUMENT in
390 -r)
391 echo "$NAME: creating configuration for root (BAD IDEA)..."
392 ;;
393 *)
394 echo "$NAME: $CONFIG not found, creating..."
395 ;;
396 esac
397
398 rm_tmpfiles
399
400 for app in $IMAGE_APPS; do
401 search_$app
402 done
403
404 if [ -z "$FULL" -o -z "$TILE" -o -z "$CENTER" ]; then
405 rm -f $TMPFILE
406 unset INFO
407 error_msg 3
408 fi
409
410 if [ ! -d ${HOME}/.fluxbox ]; then
411 mkdir ${HOME}/.fluxbox
412 fi
413
414 cat << EOF > ${CONFIG}
415
416# $CONFIG
417#
418# Automagically generated with loving care by $NAME $VERSION on `date`
419#
420# Uncomment the set below that corresponds to your favorite root-image
421# application, or mix and match to suit your pleasure.
422#
423# xli misbehaves under larger screen resolutions when using the -fullscreen
424# option. use -fullscreen if your resolution is higher than 1024x768.
425#
426
427
428### $APP
429FULL="$FULL"
430TILE="$TILE"
431CENTER="$CENTER"
432DEFAULT="$DEFAULT"
433
434EOF
435
436 grep -v ${APP} ${TMPFILE} >> ${CONFIG}
437
438 rm -f $TMPFILE
439
440 if [ -f $CONFIG ]; then
441 echo "$NAME: default configuration was created in $CONFIG."
442 else
443 echo "ERROR: $CONFIG not found!"
444 exit 1
445 fi
446}
447
448check_config_apps() {
449 BGAPP=$1
450 APP_PATH=`which $BGAPP 2>&1`
451 case ${APP_PATH} in
452 */*$BGAPP)
453 BGAPP_MSG="$APP_PATH"
454 ;;
455 *)
456 BGAPP_MSG="$BGAPP: not found"
457 APP_ERROR=`expr $APP_ERROR + 1`
458 ;;
459 esac
460}
461
462
463check_config_vars() {
464 ERROR=0
465 APP_ERROR=0
466
467 case $FB_ARG in
468 $FULL)
469 if [ -z "$FULL" ]; then
470 FULL_MSG="(no value)"
471 ERROR=`expr $ERROR + 1`
472 else
473 check_config_apps $FULL
474 FULL_BGAPP_MSG=$BGAPP_MSG
475 FULL_BGAPP=$BGAPP
476 FULL_MSG="$FULL"
477 fi
478 ;;
479 $TILE)
480 if [ -z "$TILE" ]; then
481 TILE_MSG="(no value)"
482 ERROR=`expr $ERROR + 1`
483 else
484 check_config_apps $TILE
485 TILE_BGAPP_MSG=$BGAPP_MSG
486 TILE_BGAPP=$BGAPP
487 TILE_MSG="$TILE"
488 fi
489 ;;
490 $CENTER)
491 if [ -z "$CENTER" ]; then
492 CENTER_MSG="(no value)"
493 ERROR=`expr $ERROR + 1`
494 else
495 check_config_apps $CENTER
496 CENTER_BGAPP_MSG=$BGAPP_MSG
497 CENTER_BGAPP=$BGAPP
498 CENTER_MSG="$CENTER"
499 fi
500 ;;
501 *)
502 if [ -z "$DEFAULT" ]; then
503 DEFAULT_MSG="(no value)"
504 ERROR=`expr $ERROR + 1`
505 else
506 check_config_apps $DEFAULT
507 DEFAULT_BGAPP_MSG=$BGAPP_MSG
508 DEFAULT_BGAPP=$BGAPP
509 DEFAULT_MSG="$DEFAULT"
510 fi
511 ;;
512 esac
513}
514
515
516final_error_check() {
517 case $ARGUMENT in
518 *full|-f|c)
519 OPTION=FULL
520 VALUE=$FULL_MSG
521 FB_ARG=$FULL
522 case $FULL_BGAPP_MSG in
523 *'not found')
524 APP=$FULL_BGAPP
525 error_msg nobgapp
526 ;;
527 esac
528 ;;
529 *tile|-t|t)
530 OPTION=TILE
531 VALUE=$TILE_MSG
532 FB_ARG=$TILE
533 case $TILE_BGAPP_MSG in
534 *'not found')
535 APP=$TILE_BGAPP
536 error_msg nobgapp
537 ;;
538 esac
539 ;;
540 *center|-c|c)
541 OPTION=CENTER
542 VALUE=$CENTER_MSG
543 FB_ARG=$CENTER
544 case $CENTER_BGAPP_MSG in
545 *'not found')
546 APP=$CENTER_BGAPP
547 error_msg nobgapp
548 ;;
549 esac
550 ;;
551 *last|-l|l)
552 OPTION=DEFAULT
553 VALUE=$DEFAULT_MSG
554 FB_ARG=$DEFAULT
555 ARGUMENT=default
556 case $DEFAULT_BGAPP_MSG in
557 *'not found')
558 APP=$DEFAULT_BGAPP
559 error_msg nobgapp
560 ;;
561 esac
562 ;;
563 *)
564 OPTION=DEFAULT
565 VALUE=$DEFAULT_MSG
566 FB_ARG=$DEFAULT
567 ARGUMENT=default
568 case $DEFAULT_BGAPP_MSG in
569 *'not found')
570 APP=$DEFAULT_BGAPP
571 error_msg nobgapp
572 ;;
573 esac
574
575 if [ ! "$IMAGE_EXISTS" = yes ]; then
576 error_msg 4; fi
577 ;;
578 esac
579
580 case $VALUE in
581 '(no value)')
582 if [ -n "$APP" ]; then
583 error_msg 2
584 else
585 error_msg 1
586 fi
587 ;;
588 esac
589}
590
591
592check_config() {
593 if [ ! -f $CONFIG ]; then
594 create_config
595 fi
596
597 . $CONFIG
598 check_old_config
599 final_error_check
600 check_config_vars
601}
602
603
604check_image() {
605 case "$IMAGE" in
606 *~/*)
607 IMAGE="$HOME/`basename $IMAGE`"
608 ;;
609 esac
610
611 case $NOARG in
612 yes|y|1)
613 NUM=4
614 ;;
615 *)
616 if [ -n "$IMAGE" ]; then
617 NUM=5
618 else
619 NUM=6
620 fi
621 case $IMAGE in
622 $ARGUMENT|'.'|'./')
623 error_msg 6
624 ;;
625 esac
626 esac
627
628 if [ ! -r "$IMAGE" ]; then
629 error_msg $NUM
630 else
631 IMAGE_EXISTS=yes
632 fi
633}
634
635
636exec_app() {
637 case `which $APP 2>&1` in
638 */*$APP)
639 check_image
640 final_error_check
641 exec $APP $ARGS "$IMAGE"
642 ;;
643 *)
644 check_image
645 check_config
646 exec $FB_ARG "$IMAGE"
647 ;;
648 esac
649}
650
651
652check_bsetroot_args() {
653 case $1 in
654 -mod)
655 ARGS="$1 $2 $3 $4 $5 $6 $7"
656 ;;
657 -gradient)
658 ARGS="$1 $2 $3 $4 $5 $6"
659 ;;
660 -solid)
661 ARGS="$1 $2"
662 ;;
663 esac
664}
665
666
667exec_bsetroot() {
668 case `which bsetroot 2>&1` in
669 */*bsetroot)
670 exec bsetroot $ARGS
671 ;;
672 *)
673 error_msg 7
674 ;;
675 esac
676}
677
678
679check_old_config() {
680 if [ -f $CONFIG ]; then
681 if [ -n "$BGAPP" -o -n "$CENTER_ARGS" -o \
682 -n "$TILED_ARGS" -o -n "$OTHER_ARGS" -o \
683 -n "$DEFAULT_ARGS" ]; then
684 cat << EOF >&2
685This version of $NAME ($VERSION) no longer uses the old configuration format."
686Please update $CONFIG with the new syntax:"
687
688CENTER="value"
689FULL="value"
690TILE="value"
691DEFAULT="value"
692
693Look at the sample.config file for details.
694EOF
695 exit 1
696 fi
697 fi
698}
699
700
701debug() {
702cat << EOF
703DEBUG:--------------------------
704config: $CONFIG
705full: $FULL
706tile: $TILE
707center: $CENTER
708default: $DEFAULT
709error: $ERROR
710app error: $APP_ERROR
711argument: $ARGUMENT
712________________________________
713EOF
714}
715
716IMAGE_APPS="display Esetroot wmsetbg xv xli qiv xsri"
717CONFIG="$HOME/.fluxbox/bsetbg"
718LASTIMAGEFILE="$HOME/.fluxbox/bsetbg.lastimage"
719NAME=`basename $0`
720VERSION=1.13
721MORE='(C) 2000 by lordzork industries (http://lordzork.com/)'
722PATH=$PATH:/usr/bin:/usr/local/bin:/usr/X11R6/bin:/usr/X11/bin
723TMPFILE=$CONFIG.tmp
724ARGUMENT=$1
725
726which grep > /dev/null 2> /dev/null || error_msg nogrep
727
728case $1 in
729 *-full|-f|f)
730 check_config
731 IMAGE=$2
732 check_image
733 echo -e "full\n$IMAGE" > $LASTIMAGEFILE
734 exec $FULL "$IMAGE"
735 ;;
736 *-tile|*tiled|-t|t)
737 check_config
738 IMAGE=$2
739 check_image
740 echo -e "tile\n$IMAGE" > $LASTIMAGEFILE
741 exec $TILE "$IMAGE"
742 ;;
743 *-center|-c|c)
744 check_config
745 IMAGE=$2
746 check_image
747 echo -e "center\n$IMAGE" > $LASTIMAGEFILE
748 exec $CENTER "$IMAGE"
749 ;;
750 *-last|-l|l)
751 check_config
752 LASTACTION="`head -n 1 $LASTIMAGEFILE 2> /dev/null`"
753 IMAGE="`tail -n 1 $LASTIMAGEFILE 2> /dev/null`" && check_image
754 ACTION=$DEFAULT
755 case "$LASTACTION" in
756 full) ACTION=$FULL ;;
757 tile) ACTION=$TILE ;;
758 center) ACTION=$CENTER ;;
759 *) echo "Error: $LASTIMAGEFILE is kaputt" >&2
760 exit 1
761 ;;
762 esac
763 exec $ACTION "$IMAGE"
764 ;;
765 *-app|-a|a)
766 APP=$2
767 ARGS="$3"
768 case $# in
769 4)
770 ARGUMENT=$3
771 IMAGE=$4
772 exec_app
773 ;;
774 5)
775 COMMAND=`shift && echo $*`
776 ARGUMENT=$4
777 IMAGE=$5
778 exec_app
779 ;;
780 *)
781 error_msg 8
782 ;;
783 esac
784 ;;
785 -mod|-gradient|-solid)
786 check_bsetroot_args $*
787 exec_bsetroot
788 ;;
789 -display)
790 shift 1 && check_bsetroot_args $*
791 ARGS="-display $ARGS"
792 exec_bsetroot
793 ;;
794 *-info|-i|i)
795 INFO=yes
796 check_config
797 info_msg
798 ;;
799 *-version|-v|v)
800 cat << EOF
801
802$NAME version $VERSION
803$MORE
804EOF
805 ;;
806 *-help|-h|h)
807 help_msg
808 ;;
809 -r)
810 case `whoami` in
811 root)
812 if [ -f $CONFIG ]; then
813 echo 'Error: Config already exists' >&2
814 exit 1
815 else
816 create_config
817 fi
818 ;;
819 *)
820 echo 'Error: -r is for creating a config for root and your are not root' >&2
821 exit 1
822 esac
823 ;;
824 *)
825 if [ -n "$1" ]; then
826 NOARG=yes
827 IMAGE=$1
828 check_image
829 check_config && final_error_check
830 echo -e "default\n$IMAGE" > $LASTIMAGEFILE
831 exec $DEFAULT "$1"
832 else
833 if [ ! -f $CONFIG ]; then
834 create_config
835 fi
836 help_msg
837 fi
838 ;;
839esac