display_full_cmd="display -geometry 800x600 -window root"
display_tile_cmd="display -window root"
display_center_cmd="display -backdrop -window root"
display_full_cmd="display -geometry 800x600 -window root"
display_tile_cmd="display -window root"
display_center_cmd="display -backdrop -window root"
-# this is extremely lame, but probably more portable than grep -E
- bsetroot_help=$(bsetroot -help 2>&1| grep -v "^bsetroot" | grep -v "^ -help")
- case $bsetroot_help in
- BaseDisplay*) echo ;;
- *-gradient*) echo "$bsetroot_help"
- esac
+ -display <string> use display connection
+ -mod <x> <y> modula pattern
+ -foreground, -fg <color> modula foreground color
+ -background, -bg <color> modula background color
+
+ -gradient <texture> gradient texture
+ -from <color> gradient start color
+ -to <color> gradient end color
+
+ -solid <color> solid color
-get_apps() {
- for a in $img_apps; do
- if check_exe_in_path $a; then
- eval center_cmd=\$$a\_center_cmd
- eval full_cmd=\$$a\_full_cmd
- eval tile_cmd=\$$a\_tile_cmd
- eval default_cmd=\$$a\_default_cmd
- return 0
- else
- if [ "$not_found" ]; then
- not_found="$not_found $a"
+get_apps()
+{
+ for a in $img_apps; do
+ if check_exe_in_path $a; then
+ eval center_cmd=\$$a\_center_cmd
+ eval full_cmd=\$$a\_full_cmd
+ eval tile_cmd=\$$a\_tile_cmd
+ eval default_cmd=\$$a\_default_cmd
+ return 0
-do_generate() {
- echo -e "# created by $me $version on $(date)\n#"
- echo -e "# seting NO_EXEC to a boolean value (eg true/false) will cause $me"
- echo -e "# to never modify the root window\n#"
- echo -e "#NO_EXEC=\n#"
- echo -e "# POST_COMMAND can be set to a command that will be run run every time"
- echo -e "# $me sets the root image\n#"
- echo -e "#POST_COMMAND=\n#"
- echo -e "# if LOG_LAST_CMD is set (boolean), bsetbg will keep a log of the last"
- echo -e "# two successful commands.\n#"
- echo -e "#LOG_LAST_CMD=\n#"
- echo -e "# the LOGFILE specifies the file that bsetbg uses when LOG_LAST_CMD"
- echo -e "# is defined. this defaults to ~/.bsetbg_last_cmd .\n#"
- echo -e "#LOGFILE=\n#"
- echo -e "# the following are default configuration values for the most popular image"
- echo -e "# programs. See the man page of the respective application for more info.\n"
-
- [ "$*" ] && img_apps="$*"
-
- for a in $img_apps; do
- if check_exe_in_path $a; then
- if ! bool $have_match; then
- q='\"'
- [ "$(eval echo \$$a\_center_cmd)" ] &&
- eval echo CENTER=$q\$$a\_center_cmd$q &&
+do_generate()
+{
+ echo -e "# created by $me $version on $(date)\n#"
+ echo -e "# seting NO_EXEC to a boolean value (eg true/false) will cause $me"
+ echo -e "# to never modify the root window\n#"
+ echo -e "#NO_EXEC=\n#"
+ echo -e "# POST_COMMAND can be set to a command that will be run run every time"
+ echo -e "# $me sets the root image\n#"
+ echo -e "#POST_COMMAND=\n#"
+ echo -e "# if LOG_LAST_CMD is set (boolean), bsetbg will keep a log of the last"
+ echo -e "# two successful commands.\n#"
+ echo -e "#LOG_LAST_CMD=\n#"
+ echo -e "# the LOGFILE specifies the file that bsetbg uses when LOG_LAST_CMD"
+ echo -e "# is defined. this defaults to ~/.bsetbg_last_cmd .\n#"
+ echo -e "#LOGFILE=\n#"
+ echo -e "# the following are default configuration values for the most popular image"
+ echo -e "# programs. See the man page of the respective application for more info.\n"
+
+ [ "$*" ] && img_apps="$*"
+
+ for a in $img_apps; do
+ if check_exe_in_path $a; then
+ if ! bool $have_match; then
+ q='\"'
+ [ "$(eval echo \$$a\_center_cmd)" ] &&
+ eval echo CENTER=$q\$$a\_center_cmd$q &&
- if [ -f "$file" ]; then
- exec_img_command $do_this $file
- else
- quit 1 "$file does not exist"
- fi
+ if [ -f "$file" ]; then
+ exec_img_command $do_this $file
+ else
+ quit 1 "$file does not exist"
+ fi
- # check to see if -*c, -*f, or -*t were spcified, if so
- # assume the last argument is a filename
- b_arg=$(eval echo \$$(( $# - 1 )) )
- app=$1
-
- case $b_arg in
- -c|*-center|c|-t|*-tile*|t|-f|*-full|f)
- eval file=\$$#
- f_args="$b_arg $file"
- esac
-
- # put the rest of the arguments into the varialbe $e_args
- while [ "$*" ]; do
- for a in "$*"; do
- case $1 in
- $b_arg|$file) : ;;
- *) e_args="$e_args "$1""
- esac
- shift 1
- done
- done
-
- # with $f_args defined, check for image and do things normally
- if [ "$f_args" ]; then
- [ ! -f "$file" ] && quit 1 "$file does not exist"
+ # check to see if -*c, -*f, or -*t were spcified, if so
+ # assume the last argument is a filename
+ b_arg=$(eval echo \$$(( $# - 1 )) )
+ app=$1
+
+ case $b_arg in
+ -c|*-center|c|-t|*-tile*|t|-f|*-full|f)
+ eval file=\$$#
+ f_args="$b_arg $file"
+ esac
+
+ # put the rest of the arguments into the varialbe $e_args
+ while [ "$*" ]; do
+ for a in "$*"; do
+ case $1 in
+ $b_arg|$file) : ;;
+ *) e_args="$e_args "$1""
+ esac
+ shift 1
+ done
+ done
+
+ # with $f_args defined, check for image and do things normally
+ if [ "$f_args" ]; then
+ [ ! -f "$file" ] && quit 1 "$file does not exist"
- if check_img_command $e_args; then
+ if check_img_command $e_args; then
+ do_this="$e_args"
+ else
+ read_config
+ get_img_command $f_args
+ check_img_command $do_this
+ echo "$p couldn't find '$app' in path, using $type command instead"
+ fi
+ # without $f_args, run the command blindly if it's in $PATH
+ elif check_exe_in_path $e_args; then
- else
- read_config
- get_img_command $f_args
- check_img_command $do_this
- echo "$p couldn't find '$app' in path, using $type command instead"
- fi
- # without $f_args, run the command blindly if it's in $PATH
- elif check_exe_in_path $e_args; then
- do_this="$e_args"
- else
- quit 1 "$p unable to run the following command: $e_args"
- fi
-
- exec_img_command $do_this $file
+ else
+ quit 1 "$p unable to run the following command: $e_args"
+ fi
+
+ exec_img_command $do_this $file
-get_img_command() {
- case $1 in
- *-full|-f|f) type=full; do_this="$full_cmd" ;;
- *-tile|-t|t) type=tile; do_this="$tile_cmd" ;;
- *-center|-c|c) type=center; do_this="$center_cmd" ;;
- *) type=default; do_this="$default_cmd"
- esac
+get_img_command()
+{
+ case $1 in
+ *-full|-f|f) type=full; do_this="$full_cmd" ;;
+ *-tile|-t|t) type=tile; do_this="$tile_cmd" ;;
+ *-center|-c|c) type=center; do_this="$center_cmd" ;;
+ *) type=default; do_this="$default_cmd"
+ esac
-check_img_command() {
- if check_exe_in_path $1; then
- do_this="$*"
- rc=0
- elif get_apps; then
- get_img_command $*
- rc=1
- else
- quit 1 "$p couldn't find a suitable image program. tried the following:\\n
- $(for a in $not_found; do echo " $a\\n"; done)"
- fi
-
- if [ "$rc" -gt 0 -a -z "$e_args" ] && bool $read_config; then
- echo "$p couldn't find a suitable $type command in $config"
- fi
+check_img_command()
+{
+ if check_exe_in_path $1; then
+ do_this="$*"
+ rc=0
+ elif get_apps; then
+ get_img_command $*
+ rc=1
+ else
+ quit 1 "$p couldn't find a suitable image program. tried the following:\\n
+ $(for a in $not_found; do echo " $a\\n"; done)"
+ fi
+
+ if [ "$rc" -gt 0 -a -z "$e_args" ] && bool $read_config; then
+ echo "$p couldn't find a suitable $type command in $config"
+ fi
-exec_img_command() {
- unset rc
- command=$*
-
- if [ "$debug" ]; then
- $debug $command
- else
- $command >/dev/null 2>&1; rc=$?
- fi
-
- if [ "$rc" -gt 0 ]; then
- echo "$p '$command' exited with status $rc"
- get_apps
- noconfig=1
- parse_args ${f_args:-$my_args}
- echo "$p using '$command' as $type"
- $debug $command >/dev/null 2>&1; rc=$?
- [ "$rc" = 0 ] && log_cmd $do_this $file && $refresh_cmd 2>/dev/null
- else
- log_cmd $do_this $file; xrefresh 2>/dev/null
- fi
- return $rc
+exec_img_command()
+{
+ unset rc
+ command=$*
+
+ if [ "$debug" ]; then
+ $debug $command
+ else
+ $command >/dev/null 2>&1; rc=$?
+ fi
+
+ if [ "$rc" -gt 0 ]; then
+ echo "$p '$command' exited with status $rc"
+ get_apps
+ noconfig=1
+ parse_args ${f_args:-$my_args}
+ echo "$p using '$command' as $type"
+ $debug $command >/dev/null 2>&1; rc=$?
+ [ "$rc" = 0 ] && log_cmd $do_this $file && $refresh_cmd 2>/dev/null
+ else
+ log_cmd $do_this $file; xrefresh 2>/dev/null
+ fi
+ return $rc
-log_cmd() {
- bool $LOG_LAST_CMD || return 1
- [ "$debug" ] && return 1
- echo -e "$prev_cmd\n$*" >$last_cmd_file
- return $?
+log_cmd()
+{
+ bool $LOG_LAST_CMD || return 1
+ [ "$debug" ] && return 1
+ echo -e "$prev_cmd\n$*" >$last_cmd_file
+ return $?
-post_command() {
- if [ -n "$POST_COMMAND" -a "$rc" -le 0 ]; then
- if [ -n "$debug" ]; then
- $debug "running post_command: $POST_COMMAND $post_args"
- else
- $POST_COMMAND $post_args 2>/dev/null; erc=$?
- [ "$erc" -gt 0 ] &&
- echo "$p post-command '$POST_COMMAND $post_args' exited with status $erc"
+post_command()
+{
+ bool $noconfig || read_config
+
+ if [ -n "$POST_COMMAND" -a "$1" = 0 ]; then
+ if [ -n "$debug" ]; then
+ $debug "running post_command: $POST_COMMAND $post_args"
+ else
+ post_command_output=$($POST_COMMAND $post_args 2>&1); erc=$?
+ if [ "$erc" -gt 0 ]; then
+ echo "$p post-command '$POST_COMMAND $post_args' exited with status $erc"
+ [ -n "$post_command_output" ] &&
+ echo "$POST_COMMAND $post_args: $post_command_output"
+ fi
+ fi
-add_post_arg() {
- [ -z "$1" ] && return 1
- if [ "$post_args" ]; then
- post_args="$post_args $1"
- else
- post_args=$1
- fi
+add_post_arg()
+{
+ [ -z "$1" ] && return 1
+ if [ "$post_args" ]; then
+ post_args="$post_args $1"
+ else
+ post_args=$1
+ fi
-check_cmd() {
- if [ -z "$command" ]; then
- command=${2:-$1}; eval ${3:-${2:-$1}}=1
- elif bool $do_post; then
- add_post_arg ${1}
- else
- finished=1
- fi
+check_cmd()
+{
+ if [ -z "$command" ]; then
+ command=${2:-$1}; eval ${3:-${2:-$1}}=1
+ elif bool $do_post; then
+ add_post_arg ${1}
+ elif [ "$command" = do_exec ]; then
+ do_exec=1
+ elif [ "$command" != do_bsetroot ]; then
+ finished=1
+ fi
- -c|*-center|c|-t|*-tile*|t|-f|*-full|f)
- case $command in
- do_std|do_generate|do_bsetroot)
- finished=1 ;;
- do_exec)
- if ! bool $got_fcmd; then
- add_arg $1 args; got_fcmd=1
- else
- finished=1
- fi ;;
- *)
- add_arg $1; do_std=1; command=do_std
- esac ;;
+ -c|*-center|c|-t|*-tile*|t|-f|*-full|f)
+ case $command in
+ do_standard|do_generate|do_bsetroot)
+ finished=1 ;;
+ do_exec)
+ if ! bool $got_fcmd; then
+ add_arg $1 args; got_fcmd=1
+ else
+ finished=1
+ fi ;;
+ *)
+ add_arg $1; do_standard=1; command=do_standard
+ esac ;;
- if bool $do_std || bool $do_exec || bool $do_bsetroot || bool $do_generate; then
- add_arg $1
- elif bool $do_post; then
- add_post_arg $1
- else
- add_arg $1; command=do_std; finished=1
- fi
- esac
+ if bool $do_standard || bool $do_exec || bool $do_bsetroot || bool $do_generate; then
+ add_arg $1
+ elif bool $do_post; then
+ add_post_arg $1
+ else
+ add_arg $1; command=do_standard; finished=1
+ fi
+ esac