diff options
| author | Dana Jansens <danakj@orodu.net> | 2002-04-11 03:20:38 +0000 |
|---|---|---|
| committer | Dana Jansens <danakj@orodu.net> | 2002-04-11 03:20:38 +0000 |
| commit | dfc5f034581f5a26cba5c4811500438f89f0634a (patch) | |
| tree | efb1e3af799383aa5835a736cabf658d18db4be5 /util | |
| parent | 17532e906b1dd6340bb1eccd2d9724643637958b (diff) | |
Initial revision
Diffstat (limited to 'util')
| -rw-r--r-- | util/Makefile.am | 18 | ||||
| -rw-r--r-- | util/Makefile.in | 385 | ||||
| -rw-r--r-- | util/bsetbg | 694 | ||||
| -rw-r--r-- | util/bsetroot.cc | 296 | ||||
| -rw-r--r-- | util/bsetroot.h | 33 |
5 files changed, 1426 insertions, 0 deletions
diff --git a/util/Makefile.am b/util/Makefile.am new file mode 100644 index 00000000..3c75a4c4 --- /dev/null +++ b/util/Makefile.am @@ -0,0 +1,18 @@ +# util/Makefile.am for Openbox + +CPPFLAGS= @CPPFLAGS@ @DEBUG@ @NLS@ @TIMEDCACHE@ @NEWWMSPEC@ @INTERLACE@ \ +@ORDEREDPSEUDO@ + +bin_SCRIPTS = bsetbg +bin_PROGRAMS = bsetroot + +bsetroot_SOURCES = bsetroot.cc +bsetroot_LDADD = ../src/BaseDisplay.o ../src/LinkedList.o ../src/Timer.o ../src/Image.o ../src/i18n.o + +MAINTAINERCLEANFILES = Makefile.in + +distclean-local: + rm -f *\~ + +bsetroot.o: bsetroot.cc ../config.h bsetroot.h ../src/BaseDisplay.h \ + ../src/LinkedList.h ../src/Timer.h ../src/Image.h diff --git a/util/Makefile.in b/util/Makefile.in new file mode 100644 index 00000000..aefa5e99 --- /dev/null +++ b/util/Makefile.in @@ -0,0 +1,385 @@ +# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +# util/Makefile.am for Openbox + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +CC = @CC@ +CLOBBER = @CLOBBER@ +CXX = @CXX@ +DEBUG = @DEBUG@ +INTERLACE = @INTERLACE@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +NEWWMSPEC = @NEWWMSPEC@ +NLS = @NLS@ +ORDEREDPSEUDO = @ORDEREDPSEUDO@ +PACKAGE = @PACKAGE@ +SHAPE = @SHAPE@ +SLIT = @SLIT@ +TIMEDCACHE = @TIMEDCACHE@ +VERSION = @VERSION@ +gencat_cmd = @gencat_cmd@ +regex_cmd = @regex_cmd@ + +CPPFLAGS = @CPPFLAGS@ @DEBUG@ @NLS@ @TIMEDCACHE@ @NEWWMSPEC@ @INTERLACE@ @ORDEREDPSEUDO@ + + +bin_SCRIPTS = bsetbg +bin_PROGRAMS = bsetroot + +bsetroot_SOURCES = bsetroot.cc +bsetroot_LDADD = ../src/BaseDisplay.o ../src/LinkedList.o ../src/Timer.o ../src/Image.o ../src/i18n.o + +MAINTAINERCLEANFILES = Makefile.in +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../config.h +CONFIG_CLEAN_FILES = +PROGRAMS = $(bin_PROGRAMS) + + +DEFS = @DEFS@ -I. -I$(srcdir) -I.. +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +X_CFLAGS = @X_CFLAGS@ +X_LIBS = @X_LIBS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +bsetroot_OBJECTS = bsetroot.o +bsetroot_DEPENDENCIES = ../src/BaseDisplay.o ../src/LinkedList.o \ +../src/Timer.o ../src/Image.o ../src/i18n.o +bsetroot_LDFLAGS = +SCRIPTS = $(bin_SCRIPTS) + +CXXFLAGS = @CXXFLAGS@ +CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = tar +GZIP_ENV = --best +DEP_FILES = .deps/bsetroot.P +SOURCES = $(bsetroot_SOURCES) +OBJECTS = $(bsetroot_OBJECTS) + +all: all-redirect +.SUFFIXES: +.SUFFIXES: .S .c .cc .o .s +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu util/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +mostlyclean-binPROGRAMS: + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) + +distclean-binPROGRAMS: + +maintainer-clean-binPROGRAMS: + +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(bindir) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \ + $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + list='$(bin_PROGRAMS)'; for p in $$list; do \ + rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ + done + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +bsetroot: $(bsetroot_OBJECTS) $(bsetroot_DEPENDENCIES) + @rm -f bsetroot + $(CXXLINK) $(bsetroot_LDFLAGS) $(bsetroot_OBJECTS) $(bsetroot_LDADD) $(LIBS) + +install-binSCRIPTS: $(bin_SCRIPTS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(bindir) + @list='$(bin_SCRIPTS)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`"; \ + $(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \ + else if test -f $(srcdir)/$$p; then \ + echo " $(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`"; \ + $(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \ + else :; fi; fi; \ + done + +uninstall-binSCRIPTS: + @$(NORMAL_UNINSTALL) + list='$(bin_SCRIPTS)'; for p in $$list; do \ + rm -f $(DESTDIR)$(bindir)/`echo $$p|sed '$(transform)'`; \ + done +.cc.o: + $(CXXCOMPILE) -c $< + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = util + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu util/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done + +DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) + +-include $(DEP_FILES) + +mostlyclean-depend: + +clean-depend: + +distclean-depend: + -rm -rf .deps + +maintainer-clean-depend: + +%.o: %.c + @echo '$(COMPILE) -c $<'; \ + $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-cp .deps/$(*F).pp .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm .deps/$(*F).pp + +%.lo: %.c + @echo '$(LTCOMPILE) -c $<'; \ + $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ + < .deps/$(*F).pp > .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm -f .deps/$(*F).pp + +%.o: %.cc + @echo '$(CXXCOMPILE) -c $<'; \ + $(CXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-cp .deps/$(*F).pp .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm .deps/$(*F).pp + +%.lo: %.cc + @echo '$(LTCXXCOMPILE) -c $<'; \ + $(LTCXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ + < .deps/$(*F).pp > .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm -f .deps/$(*F).pp +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: install-binPROGRAMS install-binSCRIPTS +install-exec: install-exec-am + +install-data-am: +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS +uninstall: uninstall-am +all-am: Makefile $(PROGRAMS) $(SCRIPTS) +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install +installdirs: + $(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(bindir) + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +mostlyclean-am: mostlyclean-binPROGRAMS mostlyclean-compile \ + mostlyclean-tags mostlyclean-depend mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-binPROGRAMS clean-compile clean-tags clean-depend \ + clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-binPROGRAMS distclean-compile distclean-tags \ + distclean-depend distclean-generic clean-am \ + distclean-local + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-binPROGRAMS \ + maintainer-clean-compile maintainer-clean-tags \ + maintainer-clean-depend maintainer-clean-generic \ + distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \ +maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \ +mostlyclean-compile distclean-compile clean-compile \ +maintainer-clean-compile uninstall-binSCRIPTS install-binSCRIPTS tags \ +mostlyclean-tags distclean-tags clean-tags maintainer-clean-tags \ +distdir mostlyclean-depend distclean-depend clean-depend \ +maintainer-clean-depend info-am info dvi-am dvi check check-am \ +installcheck-am installcheck install-exec-am install-exec \ +install-data-am install-data install-am install uninstall-am uninstall \ +all-redirect all-am all installdirs mostlyclean-generic \ +distclean-generic clean-generic maintainer-clean-generic clean \ +mostlyclean distclean maintainer-clean + + +distclean-local: + rm -f *\~ + +bsetroot.o: bsetroot.cc ../config.h bsetroot.h ../src/BaseDisplay.h \ + ../src/LinkedList.h ../src/Timer.h ../src/Image.h + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/util/bsetbg b/util/bsetbg new file mode 100644 index 00000000..a0675aa6 --- /dev/null +++ b/util/bsetbg @@ -0,0 +1,694 @@ +#!/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. + + +error_msg() +{ + case $INFO in yes|y|1) info_msg; esac + + case $1 in + 1) + echo; echo "$NAME: configuration error: $OPTION=\"$VALUE\"" + echo "$NAME: please edit $CONFIG and provide the correct variable." + ;; + 2) + echo; echo "$NAME: error: couldn't execute '$APP'! tried to run fallback option $ARGUMENT" + echo "$NAME: but quit because of the following error in $CONFIG:" + echo "$NAME: $OPTION= $VALUE" + echo "$NAME: please edit $CONFIG and provide the correct variable!" + ;; + 3) + echo; echo "$NAME: error: couldn't find any suitable image applications in the system path!" + echo + error_msg url + ;; + 4) + echo; echo "$NAME: error: invalid option, or non-existent image ($ARGUMENT)." + ;; + 5) + echo; echo "$NAME: error: the image you specified ($IMAGE) could not be found." + ;; + 6) + echo; echo "$NAME: error: please specify a valid image." + ;; + 7) + echo; echo "$NAME: error: bsetroot couldn't be found! check your openbox installation." + ;; + 8) + echo; echo "$NAME: error: wrong number of arguments!" + echo "$NAME: make sure you enclosed the options for '$APP' in double quotes." + ;; + nobgapp) + echo; echo "$NAME: error: tried to run '$VALUE' for $ARGUMENT argument," + echo "$NAME: but couldnt find '$APP' in the path! please fix the following" + echo "$NAME: line in $CONFIG to point to an existing application:" + echo "$NAME: $OPTION=\"$VALUE\"" + ;; + nogrep) + echo "$NAME: error: couldn't find grep!" + echo "this script needs grep to be in your path in order to function." + echo "you can get GNU grep from ftp://ftp.gnu.org/bin/gnu/grep/" && exit 1 + ;; + url) + echo "it is suggested that you use qiv, xli (xsetbg), or xv." + echo "you can obtain them at the following locations:" + echo + echo " qiv: http://www.klografx.de/software/qiv.shtml" + echo " xli: http://pantransit.reptiles.org/prog/#xli" + echo " xv: http://www.trilon.com/xv/downloads.html" + echo + echo "the above URLs are current as of 05/23/2000." + esac + exit 1 +} + + +help_msg() +{ + echo "$NAME $VERSION: $MORE" + echo "options:" + echo + echo " (none) image is set using default values" + echo + echo " -full, -f image is set fullscreen" + echo " -tile, -t image is set tiled" + echo " -center, -c image is set centered" + echo + echo " -app, -a <application> image is set using <application> with" + echo " <"'"application options"'"> quote-enclosed \"options\" and" + echo " -center, -c|-tile, -t|-full, -f default fallback option" + echo + echo " -display <string> display to connect to (bsetroot only)" + echo " -mod <x> <y> sets bsetroot modula pattern" + echo " -foreground, -fg <color> modula foreground color" + echo " -background, -bg <color> modula background color" + echo + echo " -gradient <texture> sets bsetroot gradient texture" + echo " -from <color> gradient start color" + echo " -to <color> gradient end color" + echo + echo " -solid <color> sets bsetroot solid color" + echo + echo " -version, -v outputs $NAME's version number" + echo " -info, -i outputs configuration info" + echo " -help, -h this message" + echo + echo "usage: <options...> <image>" + 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 + + echo "$NAME $VERSION configuration:" + echo + echo " bsetroot: $BSETROOT" + echo + echo " reading configuration from: $CONFIG" + echo + echo " configuration values:" + echo + 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() +{ + case `which $1 2>&1` in + */*$1) + echo "$NAME: checking for $1... `which $1`" + echo "### $app" >> $TMPFILE + echo "# FULL=\"$full\"" >> $TMPFILE + echo "# TILE=\"$tile\"" >> $TMPFILE + echo "# CENTER=\"$center\"" >> $TMPFILE + echo "# DEFAULT=\"$default\"" >> $TMPFILE + echo >> $TMPFILE + + FULL=$full + TILE=$tile + CENTER=$center + DEFAULT=$default + APP=$app + ;; + *) + echo "$NAME: checking for $1... not found." + esac +} + +search_display() +{ + ### display + full="display -geometry 800x600 -window root" + tile="display -window root" + center="display -backdrop -window root" + default=$center + find_app display +} + +search_Esetroot() +{ + ### Esetroot + full="Esetroot -scale" + tile="Esetroot" + center="Esetroot -c" + default=$center + find_app Esetroot +} + +search_wmsetbg() +{ + ### wmsetbg + full="wmsetbg -s -S" + tile="wmsetbg -t" + center="wmsetbg -e" + default=$center + find_app wmsetbg +} + +search_xli() +{ + ### 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() +{ + ### qiv + full="qiv --root_s" + tile="qiv --root_t" + center="qiv --root" + default=$center + find_app qiv +} + +search_xv() +{ + ### 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 $UID in 0) + if [ "$ARGUMENT" != "-r" ]; then + echo "$NAME: running X as root is a security hazard, and is NOT a good idea!" + echo "$NAME: if you insist upon having a ~/.bsetbgrc for root, run bsetbg with" + echo "$NAME: the '-r' flag to force its creation. you have been warned!" + exit 1 + fi + esac + + case $ARGUMENT in + -r) + echo "$NAME: creating configuration for root (BAD IDEA)..." + ;; + *) + echo "$NAME: $CONFIG not found, creating..." + esac + + for app in $IMAGE_APPS; do + search_$app + done + + if [ -z "$FULL" ] || [ -z "TILE" ] || [ -z "$CENTER" ]; then + rm -f $TMPFILE + INFO= && error_msg 3 + fi + + echo "# $CONFIG" >> $CONFIG + echo "#" >> $CONFIG + echo "# automagically generated with loving care by $NAME $VERSION on `date`" >> $CONFIG + echo "#" >> $CONFIG + echo "# uncomment the set below that corresponds to your favorite root-image" >> $CONFIG + echo "# application, or mix and match to suit your pleasure." >> $CONFIG + echo "#" >> $CONFIG + echo "# xli misbehaves under larger screen resolutions when using the -fillscreen" >> $CONFIG + echo "# option. use -fullscreen if your resolution is higher than 1024x768." >> $CONFIG + echo "#" >> $CONFIG + echo; echo >> $CONFIG + echo "### $APP" >> $CONFIG + echo "FULL=\"$FULL\"" >> $CONFIG + echo "TILE=\"$TILE\"" >> $CONFIG + echo "CENTER=\"$CENTER\"" >> $CONFIG + echo "DEFAULT=\"$DEFAULT\"" >> $CONFIG + echo >> $CONFIG + + cat $TMPFILE | grep -v $APP >> $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 + case `which $1 2>&1` in + */*$1) + BGAPP_MSG="`which $1`" + ;; + *) + BGAPP_MSG="$BGAPP: not found" + APP_ERROR=`expr $APP_ERROR + 1` + esac +} + + +check_config_vars() +{ + ERROR=0 + APP_ERROR=0 + + 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 + + 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 + + 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 +} + + +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 + ;; + *) + 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 + + check_old_config + . $CONFIG + check_config_vars + final_error_check +} + + +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 [ ! -e "$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 + . $CONFIG + if [ -n "$BGAPP" ] || [ -n "$CENTER_ARGS" ] || \ + [ -n "$TILED_ARGS" ] || [ -n "$OTHER_ARGS" ] || \ + [ -n "$DEFAULT_ARGS" ]; then + echo " this version of $NAME ($VERSION) no longer uses the old configuration format." + echo " please update $CONFIG with the new syntax:" + echo + echo " CENTER=\"value\"" + echo " FULL=\"value\"" + echo " TILE=\"value\"" + echo " DEFAULT=\"value\"" + echo + echo " see the sample.config file for details." + exit 0 + fi + fi +} + + +debug() +{ + echo "DEBUG:--------------------------" + echo "config: $CONFIG" + echo "full: $FULL" + echo "tile: $TILE" + echo "center: $CENTER" + echo "default: $DEFAULT" + echo "error: $ERROR" + echo "app error: $APP_ERROR" + echo "argument: $ARGUMENT" + echo "________________________________" + echo +} + +IMAGE_APPS="display Esetroot wmsetbg xv xli qiv" +CONFIG="$HOME/.bsetbgrc" +NAME=bsetbg +VERSION=1.12 +MORE="(C) 2000 by lordzork industries (http://lordzork.com/)" +PATH=$PATH:/usr/bin:/usr/local/bin:/usr/X11R6/bin:/usr/X11/bin +TMPFILE=`tempfile --prefix=bsetbg` +ARGUMENT=$1 + + +case `which grep 2>&1` in */*grep) : ;; + *) + error_msg nogrep +esac + +case $1 in + *-full|-f|f) + check_config + IMAGE=$2 && check_image + exec $FULL "$IMAGE" + ;; + *-tile|*tiled|-t|t) + check_config + IMAGE=$2 && check_image + exec $TILE "$IMAGE" + ;; + *-center|-c|c) + check_config + IMAGE=$2 && check_image + exec $CENTER "$IMAGE" + ;; + *-app|-a|a) + APP=$2 + ARGS="$3" + case $# in + 4) + ARGMENT=$3 + IMAGE=$4 + exec_app + ;; + 5) + COMMAND=`shift 1 && 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) + echo; echo " $NAME version $VERSION"; echo " $MORE"; exit 0 + ;; + *-help|-h|h) + help_msg + ;; + -r) + case $UID in + 0) + if [ -f $CONFIG ]; then + exit 1 + else + create_config + fi + ;; + *) + exit 1 + esac + ;; + *) + if [ -n "$1" ]; then + NOARG=yes + IMAGE=$1 && check_image + check_config && final_error_check + exec $DEFAULT "$1" + else + if [ ! -f $CONFIG ]; then + create_config && exit 0 + fi + help_msg + fi +esac diff --git a/util/bsetroot.cc b/util/bsetroot.cc new file mode 100644 index 00000000..f0912cab --- /dev/null +++ b/util/bsetroot.cc @@ -0,0 +1,296 @@ +#ifdef HAVE_CONFIG_H +# include "../config.h" +#endif // HAVE_CONFIG_H + +#ifdef STDC_HEADERS +# include <string.h> +# include <stdlib.h> +#endif // STDC_HEADERS + +#ifdef HAVE_STDIO_H +# include <stdio.h> +#endif // HAVE_STDIO_H + +#include "../src/i18n.h" +#include "bsetroot.h" + + +bsetroot::bsetroot(int argc, char **argv, char *dpy_name) + : BaseDisplay(argv[0], dpy_name) +{ + pixmaps = (Pixmap *) 0; + grad = fore = back = (char *) 0; + + Bool mod = False, sol = False, grd = False; + int mod_x = 0, mod_y = 0, i = 0; + + img_ctrl = new BImageControl*[getNumberOfScreens()]; + for (; i < getNumberOfScreens(); i++) + img_ctrl[i] = new BImageControl(this, getScreenInfo(i), True); + + for (i = 1; i < argc; i++) { + if (! strcmp("-help", argv[i])) { + usage(); + } else if ((! strcmp("-fg", argv[i])) || + (! strcmp("-foreground", argv[i])) || + (! strcmp("-from", argv[i]))) { + if ((++i) >= argc) usage(1); + + fore = argv[i]; + } else if ((! strcmp("-bg", argv[i])) || + (! strcmp("-background", argv[i])) || + (! strcmp("-to", argv[i]))) { + if ((++i) >= argc) usage(1); + + back = argv[i]; + } else if (! strcmp("-solid", argv[i])) { + if ((++i) >= argc) usage(1); + + fore = argv[i]; + sol = True; + } else if (! strcmp("-mod", argv[i])) { + if ((++i) >= argc) usage(); + + mod_x = atoi(argv[i]); + + if ((++i) >= argc) usage(); + + mod_y = atoi(argv[i]); + + if (mod_x < 1) mod_x = 1; + if (mod_y < 1) mod_y = 1; + + mod = True; + } else if (! strcmp("-gradient", argv[i])) { + if ((++i) >= argc) usage(); + + grad = argv[i]; + grd = True; + } else if (! strcmp("-display", argv[i])) { + // -display passed through tests ealier... we just skip it now + i++; + } else + usage(); + } + + if ((mod + sol + grd) != True) { + fprintf(stderr, + i18n-> + getMessage( +#ifdef NLS + bsetrootSet, bsetrootMustSpecify, +#else // !NLS + 0, 0, +#endif // NLS + "%s: error: must specify one of: -solid, -mod, -gradient\n"), + getApplicationName()); + + usage(2); + } + + if (sol && fore) solid(); + else if (mod && mod_x && mod_y && fore && back) modula(mod_x, mod_y); + else if (grd && grad && fore && back) gradient(); + else usage(); +} + + +bsetroot::~bsetroot(void) { + XKillClient(getXDisplay(), AllTemporary); + + if (pixmaps) { + int i; + for (i = 0; i < getNumberOfScreens(); i++) + if (pixmaps[i] != None) { + XSetCloseDownMode(getXDisplay(), RetainTemporary); + break; + } + + delete [] pixmaps; + } + + if (img_ctrl) { + int i = 0; + for (; i < getNumberOfScreens(); i++) + delete img_ctrl[i]; + + delete [] img_ctrl; + } +} + + +void bsetroot::solid(void) { + register int screen = 0; + + for (; screen < getNumberOfScreens(); screen++) { + BColor c; + + img_ctrl[screen]->parseColor(&c, fore); + if (! c.isAllocated()) c.setPixel(BlackPixel(getXDisplay(), screen)); + + XSetWindowBackground(getXDisplay(), getScreenInfo(screen)->getRootWindow(), + c.getPixel()); + XClearWindow(getXDisplay(), getScreenInfo(screen)->getRootWindow()); + } +} + + +void bsetroot::modula(int x, int y) { + char data[32]; + long pattern; + + register int screen, i; + + pixmaps = new Pixmap[getNumberOfScreens()]; + + for (pattern = 0, screen = 0; screen < getNumberOfScreens(); screen++) { + for (i = 0; i < 16; i++) { + pattern <<= 1; + if ((i % x) == 0) + pattern |= 0x0001; + } + + for (i = 0; i < 16; i++) + if ((i % y) == 0) { + data[(i * 2)] = (char) 0xff; + data[(i * 2) + 1] = (char) 0xff; + } else { + data[(i * 2)] = pattern & 0xff; + data[(i * 2) + 1] = (pattern >> 8) & 0xff; + } + + BColor f, b; + GC gc; + Pixmap bitmap; + XGCValues gcv; + + bitmap = + XCreateBitmapFromData(getXDisplay(), + getScreenInfo(screen)->getRootWindow(), data, + 16, 16); + + img_ctrl[screen]->parseColor(&f, fore); + img_ctrl[screen]->parseColor(&b, back); + + if (! f.isAllocated()) f.setPixel(WhitePixel(getXDisplay(), screen)); + if (! b.isAllocated()) b.setPixel(BlackPixel(getXDisplay(), screen)); + + gcv.foreground = f.getPixel(); + gcv.background = b.getPixel(); + + gc = XCreateGC(getXDisplay(), getScreenInfo(screen)->getRootWindow(), + GCForeground | GCBackground, &gcv); + + pixmaps[screen] = + XCreatePixmap(getXDisplay(), getScreenInfo(screen)->getRootWindow(), + 16, 16, getScreenInfo(screen)->getDepth()); + + XCopyPlane(getXDisplay(), bitmap, pixmaps[screen], gc, + 0, 0, 16, 16, 0, 0, 1l); + XSetWindowBackgroundPixmap(getXDisplay(), + getScreenInfo(screen)->getRootWindow(), + pixmaps[screen]); + XClearWindow(getXDisplay(), getScreenInfo(screen)->getRootWindow()); + + XFreeGC(getXDisplay(), gc); + XFreePixmap(getXDisplay(), bitmap); + + if (! (getScreenInfo(screen)->getVisual()->c_class & 1)) { + XFreePixmap(getXDisplay(), pixmaps[screen]); + pixmaps[screen] = None; + } + } +} + + +void bsetroot::gradient(void) { + register int screen; + + pixmaps = new Pixmap[getNumberOfScreens()]; + + for (screen = 0; screen < getNumberOfScreens(); screen++) { + BTexture texture; + img_ctrl[screen]->parseTexture(&texture, grad); + img_ctrl[screen]->parseColor(texture.getColor(), fore); + img_ctrl[screen]->parseColor(texture.getColorTo(), back); + + if (! texture.getColor()->isAllocated()) + texture.getColor()->setPixel(WhitePixel(getXDisplay(), screen)); + if (! texture.getColorTo()->isAllocated()) + texture.getColorTo()->setPixel(BlackPixel(getXDisplay(), screen)); + + pixmaps[screen] = + img_ctrl[screen]->renderImage(getScreenInfo(screen)->getWidth(), + getScreenInfo(screen)->getHeight(), + &texture); + + XSetWindowBackgroundPixmap(getXDisplay(), + getScreenInfo(screen)->getRootWindow(), + pixmaps[screen]); + XClearWindow(getXDisplay(), getScreenInfo(screen)->getRootWindow()); + + if (! (getScreenInfo(screen)->getVisual()->c_class & 1)) { + img_ctrl[screen]->removeImage(pixmaps[screen]); + img_ctrl[screen]->timeout(); + pixmaps[screen] = None; + } + } +} + + +void bsetroot::usage(int exit_code) { + fprintf(stderr, + i18n-> + getMessage( +#ifdef NLS + bsetrootSet, bsetrootUsage, +#else // !NLS + 0, 0, +#endif // NLS + "%s 2.0 : (c) 1997-1999 Brad Hughes\n\n" + " -display <string> display connection\n" + " -mod <x> <y> modula pattern\n" + " -foreground, -fg <color> modula foreground color\n" + " -background, -bg <color> modula background color\n\n" + " -gradient <texture> gradient texture\n" + " -from <color> gradient start color\n" + " -to <color> gradient end color\n\n" + " -solid <color> solid color\n\n" + " -help print this help text and exit\n"), + getApplicationName()); + + exit(exit_code); +} + + +int main(int argc, char **argv) { + char *display_name = (char *) 0; + int i = 1; + + NLSInit("openbox.cat"); + + for (; i < argc; i++) { + if (! strcmp(argv[i], "-display")) { + // check for -display option + + if ((++i) >= argc) { + fprintf(stderr, + i18n->getMessage( +#ifdef NLS + mainSet, mainDISPLAYRequiresArg, +#else // !NLS + 0, 0, +#endif // NLS + "error: '-display' requires an argument\n")); + + ::exit(1); + } + + display_name = argv[i]; + } + } + + bsetroot app(argc, argv, display_name); + + return 0; +} diff --git a/util/bsetroot.h b/util/bsetroot.h new file mode 100644 index 00000000..ca535562 --- /dev/null +++ b/util/bsetroot.h @@ -0,0 +1,33 @@ +#ifndef __bsetroot2_hh +#define __bsetroot2_hh + +#include "../src/BaseDisplay.h" +#include "../src/Image.h" + + +class bsetroot : public BaseDisplay { +private: + BImageControl **img_ctrl; + Pixmap *pixmaps; + + char *fore, *back, *grad; + + +protected: + inline virtual void process_event(XEvent *) { } + + +public: + bsetroot(int, char **, char * = 0); + ~bsetroot(void); + + inline virtual Bool handleSignal(int) { return False; } + + void gradient(void); + void modula(int, int); + void solid(void); + void usage(int = 0); +}; + + +#endif // __bsetroot2_hh |
