new version of bsetbg
bsetroot now plays niecly with Eterm. Also, updated to the latest bsetroot from blackbox cvs
This commit is contained in:
parent
f75083669f
commit
f7ace0fad8
2 changed files with 354 additions and 324 deletions
640
util/bsetbg
640
util/bsetbg
|
@ -22,6 +22,8 @@
|
||||||
|
|
||||||
PATH=$PATH:/usr/bin:/usr/local/bin:/usr/X11R6/bin
|
PATH=$PATH:/usr/bin:/usr/local/bin:/usr/X11R6/bin
|
||||||
|
|
||||||
|
img_apps="qiv xli xv wmsetbg Esetroot display xsetbg"
|
||||||
|
|
||||||
display_full_cmd="display -geometry 800x600 -window root"
|
display_full_cmd="display -geometry 800x600 -window root"
|
||||||
display_tile_cmd="display -window root"
|
display_tile_cmd="display -window root"
|
||||||
display_center_cmd="display -backdrop -window root"
|
display_center_cmd="display -backdrop -window root"
|
||||||
|
@ -52,47 +54,52 @@ xli_tile_cmd="xli -onroot -quiet"
|
||||||
xli_center_cmd="xli -center -onroot quiet"
|
xli_center_cmd="xli -center -onroot quiet"
|
||||||
xli_default_cmd="$xli_center_cmd"
|
xli_default_cmd="$xli_center_cmd"
|
||||||
|
|
||||||
xsetbg_full_cmd="xsetbg -fullscreen"
|
xsetbg_full_cmd="xsetbg -fillscreen"
|
||||||
xsetbg_tile_cmd="xsetbg"
|
xsetbg_tile_cmd="xsetbg"
|
||||||
xsetbg_center_cmd="xsetbg -center"
|
xsetbg_center_cmd="xsetbg -center"
|
||||||
xsetbg_default_cmd="$xsetbg_center_cmd"
|
xsetbg_default_cmd="$xsetbg_center_cmd"
|
||||||
|
|
||||||
img_apps="qiv xli xv wmsetbg Esetroot display xsetbg"
|
##################################
|
||||||
|
|
||||||
me=${0##*/}
|
me=${0##*/}
|
||||||
version=2.0
|
version=2.1
|
||||||
copyright="(c) 2000-$(date +%Y) by Timothy M. King (http://lordzork.com/)"
|
copyright="(c) 2000-$(date +%Y) by Timothy M. King (http://lordzork.com/)"
|
||||||
config=$HOME/.bsetbgrc
|
config=$HOME/.bsetbgrc
|
||||||
last_cmd_file=$HOME/.bsetbg_last_cmd
|
last_cmd_file=$HOME/.bsetbg_last_cmd
|
||||||
refresh_cmd=xrefresh
|
refresh_cmd=xrefresh
|
||||||
p=$me:
|
p=$me:
|
||||||
|
|
||||||
quit() {
|
quit()
|
||||||
[ "$1" ] && rc=$1 && shift 1
|
{
|
||||||
[ "$*" ] && echo -e $*
|
[ "$1" ] && rc=$1 && shift 1
|
||||||
exit ${rc:-0}
|
[ "$*" ] && echo -e $*
|
||||||
|
exit ${rc:-0}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool() {
|
bool()
|
||||||
case $1 in
|
{
|
||||||
[yY][eE][sS]|1|[yY]|[tT][rR][uU][eE]|[oO][nN]) : ;;
|
case $1 in
|
||||||
*) return 1 ;;
|
[yY][eE][sS]|1|[yY]|[tT][rR][uU][eE]|[oO][nN]) : ;;
|
||||||
esac
|
*) return 1 ;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
check_exe_in_path() {
|
check_exe_in_path()
|
||||||
if [ -z "$1" ]; then
|
{
|
||||||
return 1
|
if [ -z "$1" ]; then
|
||||||
elif [ -x "$(which $1 2>/dev/null)" ]; then
|
return 1
|
||||||
return 0
|
elif [ -x "$(which $1 2>/dev/null)" ]; then
|
||||||
elif [ -x "$(type $1 2>/dev/null)" ]; then
|
return 0
|
||||||
return 0
|
elif [ -x "$(type $1 2>/dev/null)" ]; then
|
||||||
else
|
return 0
|
||||||
return 1
|
else
|
||||||
fi
|
return 1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
help_msg() {
|
help_msg()
|
||||||
cat <<EOF
|
{
|
||||||
|
cat <<EOF
|
||||||
$me $version $copyright
|
$me $version $copyright
|
||||||
|
|
||||||
-center <file> center an image on the desktop
|
-center <file> center an image on the desktop
|
||||||
|
@ -104,356 +111,375 @@ $me $version $copyright
|
||||||
-debug prints commands without executing them
|
-debug prints commands without executing them
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# this is extremely lame, but probably more portable than grep -E
|
# this is extremely lame, but probably more portable than grep -E
|
||||||
bsetroot_help=$(bsetroot -help 2>&1| grep -v "^bsetroot" | grep -v "^ -help")
|
bsetroot_help=$(bsetroot -help 2>&1| grep -v "^bsetroot" | grep -v "^ -help")
|
||||||
case $bsetroot_help in
|
case $bsetroot_help in
|
||||||
BaseDisplay*) echo ;;
|
BaseDisplay*) echo ;;
|
||||||
*-gradient*) echo "$bsetroot_help"
|
*-gradient*) echo "$bsetroot_help"
|
||||||
esac
|
esac
|
||||||
|
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
-generate <string> generate a config file
|
-generate <string> generate a config file
|
||||||
-help this message
|
-help this message
|
||||||
-version output version information
|
-version output version information
|
||||||
EOF
|
EOF
|
||||||
quit ${1:-0}
|
quit ${1:-0}
|
||||||
}
|
}
|
||||||
|
|
||||||
get_apps() {
|
get_apps()
|
||||||
for a in $img_apps; do
|
{
|
||||||
if check_exe_in_path $a; then
|
for a in $img_apps; do
|
||||||
eval center_cmd=\$$a\_center_cmd
|
if check_exe_in_path $a; then
|
||||||
eval full_cmd=\$$a\_full_cmd
|
eval center_cmd=\$$a\_center_cmd
|
||||||
eval tile_cmd=\$$a\_tile_cmd
|
eval full_cmd=\$$a\_full_cmd
|
||||||
eval default_cmd=\$$a\_default_cmd
|
eval tile_cmd=\$$a\_tile_cmd
|
||||||
return 0
|
eval default_cmd=\$$a\_default_cmd
|
||||||
else
|
return 0
|
||||||
if [ "$not_found" ]; then
|
|
||||||
not_found="$not_found $a"
|
|
||||||
else
|
else
|
||||||
not_found=$a
|
if [ "$not_found" ]; then
|
||||||
|
not_found="$not_found $a"
|
||||||
|
else
|
||||||
|
not_found=$a
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
done
|
||||||
done
|
return 1
|
||||||
return 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
do_generate() {
|
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 "# created by $me $version on $(date)\n#"
|
||||||
echo -e "# to never modify the root window\n#"
|
echo -e "# seting NO_EXEC to a boolean value (eg true/false) will cause $me"
|
||||||
echo -e "#NO_EXEC=\n#"
|
echo -e "# to never modify the root window\n#"
|
||||||
echo -e "# POST_COMMAND can be set to a command that will be run run every time"
|
echo -e "#NO_EXEC=\n#"
|
||||||
echo -e "# $me sets the root image\n#"
|
echo -e "# POST_COMMAND can be set to a command that will be run run every time"
|
||||||
echo -e "#POST_COMMAND=\n#"
|
echo -e "# $me sets the root image\n#"
|
||||||
echo -e "# if LOG_LAST_CMD is set (boolean), bsetbg will keep a log of the last"
|
echo -e "#POST_COMMAND=\n#"
|
||||||
echo -e "# two successful commands.\n#"
|
echo -e "# if LOG_LAST_CMD is set (boolean), bsetbg will keep a log of the last"
|
||||||
echo -e "#LOG_LAST_CMD=\n#"
|
echo -e "# two successful commands.\n#"
|
||||||
echo -e "# the LOGFILE specifies the file that bsetbg uses when LOG_LAST_CMD"
|
echo -e "#LOG_LAST_CMD=\n#"
|
||||||
echo -e "# is defined. this defaults to ~/.bsetbg_last_cmd .\n#"
|
echo -e "# the LOGFILE specifies the file that bsetbg uses when LOG_LAST_CMD"
|
||||||
echo -e "#LOGFILE=\n#"
|
echo -e "# is defined. this defaults to ~/.bsetbg_last_cmd .\n#"
|
||||||
echo -e "# the following are default configuration values for the most popular image"
|
echo -e "#LOGFILE=\n#"
|
||||||
echo -e "# programs. See the man page of the respective application for more info.\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="$*"
|
[ "$*" ] && img_apps="$*"
|
||||||
|
|
||||||
for a in $img_apps; do
|
for a in $img_apps; do
|
||||||
if check_exe_in_path $a; then
|
if check_exe_in_path $a; then
|
||||||
if ! bool $have_match; then
|
if ! bool $have_match; then
|
||||||
q='\"'
|
q='\"'
|
||||||
[ "$(eval echo \$$a\_center_cmd)" ] &&
|
[ "$(eval echo \$$a\_center_cmd)" ] &&
|
||||||
eval echo CENTER=$q\$$a\_center_cmd$q &&
|
eval echo CENTER=$q\$$a\_center_cmd$q &&
|
||||||
|
|
||||||
[ "$(eval echo \$$a\_full_cmd)" ] &&
|
[ "$(eval echo \$$a\_full_cmd)" ] &&
|
||||||
eval echo FULL=$q\$$a\_full_cmd$q &&
|
eval echo FULL=$q\$$a\_full_cmd$q &&
|
||||||
|
|
||||||
[ "$(eval echo \$$a\_tile_cmd)" ] &&
|
[ "$(eval echo \$$a\_tile_cmd)" ] &&
|
||||||
eval echo TILE=$q\$$a\_tile_cmd$q &&
|
eval echo TILE=$q\$$a\_tile_cmd$q &&
|
||||||
|
|
||||||
[ "$(eval echo \$$a\_default_cmd)" ] &&
|
[ "$(eval echo \$$a\_default_cmd)" ] &&
|
||||||
eval echo -e DEFAULT=$q\$$a\_default_cmd$q \\\\n &&
|
eval echo -e DEFAULT=$q\$$a\_default_cmd$q \\\\n &&
|
||||||
|
|
||||||
have_match=1
|
have_match=1
|
||||||
else
|
else
|
||||||
[ "$(eval echo \$$a\_center_cmd)" ] &&
|
[ "$(eval echo \$$a\_center_cmd)" ] &&
|
||||||
eval echo \\#CENTER=$q\$$a\_center_cmd$q
|
eval echo \\#CENTER=$q\$$a\_center_cmd$q
|
||||||
|
|
||||||
[ "$(eval echo \$$a\_full_cmd)" ] &&
|
[ "$(eval echo \$$a\_full_cmd)" ] &&
|
||||||
eval echo \\#FULL=$q\$$a\_full_cmd$q
|
eval echo \\#FULL=$q\$$a\_full_cmd$q
|
||||||
|
|
||||||
[ "$(eval echo \$$a\_tile_cmd)" ] &&
|
[ "$(eval echo \$$a\_tile_cmd)" ] &&
|
||||||
eval echo \\#TILE=$q\$$a\_tile_cmd$q
|
eval echo \\#TILE=$q\$$a\_tile_cmd$q
|
||||||
|
|
||||||
[ "$(eval echo \$$a\_default_cmd)" ] &&
|
[ "$(eval echo \$$a\_default_cmd)" ] &&
|
||||||
eval echo -e \\#DEFAULT=$q\$$a\_default_cmd$q \\\\n
|
eval echo -e \\#DEFAULT=$q\$$a\_default_cmd$q \\\\n
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
done
|
||||||
done
|
quit 0
|
||||||
quit 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
do_bsetroot() {
|
do_bsetroot()
|
||||||
if check_exe_in_path bsetroot; then
|
{
|
||||||
read_config
|
if check_exe_in_path bsetroot; then
|
||||||
|
read_config
|
||||||
|
|
||||||
$debug bsetroot $* 2>/dev/null; rc=$?
|
$debug bsetroot $* 2>/dev/null; rc=$?
|
||||||
|
|
||||||
if [ "$rc" -gt 0 ]; then
|
if [ "$rc" -gt 0 ]; then
|
||||||
help_msg $rc
|
help_msg $rc
|
||||||
|
else
|
||||||
|
log_cmd bsetroot $*; $refresh_cmd 2>/dev/null
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
log_cmd bsetroot $*; $refresh_cmd 2>/dev/null
|
quit 1 "couldn't find bsetroot in $PATH"
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
quit 1 "couldn't find bsetroot in $PATH"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
do_std() {
|
do_standard()
|
||||||
[ -z "$1" ] && help_msg 1
|
{
|
||||||
|
[ -z "$1" ] && help_msg 1
|
||||||
|
|
||||||
bool $noconfig || read_config
|
bool $noconfig || read_config
|
||||||
|
|
||||||
get_img_command $1
|
get_img_command $1
|
||||||
check_img_command $do_this
|
check_img_command $do_this
|
||||||
|
|
||||||
case $# in
|
case $# in
|
||||||
1) file="$1" ;;
|
1) file="$1" ;;
|
||||||
*) file="$2"
|
*) file="$2"
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ -f "$file" ]; then
|
if [ -f "$file" ]; then
|
||||||
exec_img_command $do_this $file
|
exec_img_command $do_this $file
|
||||||
else
|
else
|
||||||
quit 1 "$file does not exist"
|
quit 1 "$file does not exist"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
do_exec() {
|
do_exec()
|
||||||
[ "$#" -lt 3 ] && help_msg 3
|
{
|
||||||
|
[ "$#" -lt 3 ] && help_msg 3
|
||||||
|
|
||||||
bool $noconfig || read_config
|
bool $noconfig || read_config
|
||||||
|
|
||||||
# check to see if -*c, -*f, or -*t were spcified, if so
|
# check to see if -*c, -*f, or -*t were spcified, if so
|
||||||
# assume the last argument is a filename
|
# assume the last argument is a filename
|
||||||
b_arg=$(eval echo \$$(( $# - 1 )) )
|
b_arg=$(eval echo \$$(( $# - 1 )) )
|
||||||
app=$1
|
app=$1
|
||||||
|
|
||||||
case $b_arg in
|
case $b_arg in
|
||||||
-c|*-center|c|-t|*-tile*|t|-f|*-full|f)
|
-c|*-center|c|-t|*-tile*|t|-f|*-full|f)
|
||||||
eval file=\$$#
|
eval file=\$$#
|
||||||
f_args="$b_arg $file"
|
f_args="$b_arg $file"
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# put the rest of the arguments into the varialbe $e_args
|
# put the rest of the arguments into the varialbe $e_args
|
||||||
while [ "$*" ]; do
|
while [ "$*" ]; do
|
||||||
for a in "$*"; do
|
for a in "$*"; do
|
||||||
case $1 in
|
case $1 in
|
||||||
$b_arg|$file) : ;;
|
$b_arg|$file) : ;;
|
||||||
*) e_args="$e_args "$1""
|
*) e_args="$e_args "$1""
|
||||||
esac
|
esac
|
||||||
shift 1
|
shift 1
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
# with $f_args defined, check for image and do things normally
|
# with $f_args defined, check for image and do things normally
|
||||||
if [ "$f_args" ]; then
|
if [ "$f_args" ]; then
|
||||||
[ ! -f "$file" ] && quit 1 "$file does not exist"
|
[ ! -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
|
||||||
do_this="$e_args"
|
do_this="$e_args"
|
||||||
else
|
else
|
||||||
read_config
|
quit 1 "$p unable to run the following command: $e_args"
|
||||||
get_img_command $f_args
|
fi
|
||||||
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
|
exec_img_command $do_this $file
|
||||||
}
|
}
|
||||||
|
|
||||||
get_img_command() {
|
get_img_command()
|
||||||
case $1 in
|
{
|
||||||
*-full|-f|f) type=full; do_this="$full_cmd" ;;
|
case $1 in
|
||||||
*-tile|-t|t) type=tile; do_this="$tile_cmd" ;;
|
*-full|-f|f) type=full; do_this="$full_cmd" ;;
|
||||||
*-center|-c|c) type=center; do_this="$center_cmd" ;;
|
*-tile|-t|t) type=tile; do_this="$tile_cmd" ;;
|
||||||
*) type=default; do_this="$default_cmd"
|
*-center|-c|c) type=center; do_this="$center_cmd" ;;
|
||||||
esac
|
*) type=default; do_this="$default_cmd"
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
check_img_command() {
|
check_img_command()
|
||||||
if check_exe_in_path $1; then
|
{
|
||||||
do_this="$*"
|
if check_exe_in_path $1; then
|
||||||
rc=0
|
do_this="$*"
|
||||||
elif get_apps; then
|
rc=0
|
||||||
get_img_command $*
|
elif get_apps; then
|
||||||
rc=1
|
get_img_command $*
|
||||||
else
|
rc=1
|
||||||
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
|
|
||||||
|
|
||||||
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 $?
|
|
||||||
}
|
|
||||||
|
|
||||||
read_config() {
|
|
||||||
[ -f $config ] || return 1
|
|
||||||
|
|
||||||
if bool $read_config; then
|
|
||||||
unset read_config
|
|
||||||
else
|
|
||||||
read_config=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
. $HOME/.bsetbgrc 2>/dev/null
|
|
||||||
check_no_exec
|
|
||||||
|
|
||||||
full_cmd=$FULL
|
|
||||||
center_cmd=$CENTER
|
|
||||||
tile_cmd=$TILE
|
|
||||||
default_cmd=$CENTER
|
|
||||||
last_cmd_file=${LOGFILE:-$last_cmd_file}
|
|
||||||
|
|
||||||
bool $LOG_LAST_CMD && prev_cmd=$(tail -n 1 $last_cmd_file 2>/dev/null)
|
|
||||||
}
|
|
||||||
|
|
||||||
check_no_exec() {
|
|
||||||
bool $NO_EXEC &&
|
|
||||||
quit 0 "$p no_exec mode. the root window will not be modified."
|
|
||||||
}
|
|
||||||
|
|
||||||
post_command() {
|
|
||||||
if [ -n "$POST_COMMAND" -a "$rc" -le 0 ]; then
|
|
||||||
if [ -n "$debug" ]; then
|
|
||||||
$debug "running post_command: $POST_COMMAND $post_args"
|
|
||||||
else
|
else
|
||||||
$POST_COMMAND $post_args 2>/dev/null; erc=$?
|
quit 1 "$p couldn't find a suitable image program. tried the following:\\n
|
||||||
[ "$erc" -gt 0 ] &&
|
$(for a in $not_found; do echo " $a\\n"; done)"
|
||||||
echo "$p post-command '$POST_COMMAND $post_args' exited with status $erc"
|
|
||||||
fi
|
fi
|
||||||
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
|
||||||
|
|
||||||
|
return $rc
|
||||||
}
|
}
|
||||||
|
|
||||||
add_arg() {
|
exec_img_command()
|
||||||
[ "$1" ] || return 1
|
{
|
||||||
if [ "$args" ]; then
|
unset rc
|
||||||
args="$args $1"
|
command=$*
|
||||||
else
|
|
||||||
args=$1
|
if [ "$debug" ]; then
|
||||||
fi
|
$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 $?
|
||||||
|
}
|
||||||
|
|
||||||
|
read_config()
|
||||||
|
{
|
||||||
|
[ -f $config ] || return 1
|
||||||
|
|
||||||
|
if bool $read_config; then
|
||||||
|
unset read_config
|
||||||
|
else
|
||||||
|
read_config=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
. $HOME/.bsetbgrc 2>/dev/null
|
||||||
|
check_no_exec
|
||||||
|
|
||||||
|
full_cmd=$FULL
|
||||||
|
center_cmd=$CENTER
|
||||||
|
tile_cmd=$TILE
|
||||||
|
default_cmd=$CENTER
|
||||||
|
last_cmd_file=${LOGFILE:-$last_cmd_file}
|
||||||
|
|
||||||
|
bool $LOG_LAST_CMD && prev_cmd=$(tail -n 1 $last_cmd_file 2>/dev/null)
|
||||||
|
}
|
||||||
|
|
||||||
|
check_no_exec()
|
||||||
|
{
|
||||||
|
bool $NO_EXEC &&
|
||||||
|
quit 0 "$p no_exec mode. the root window will not be modified."
|
||||||
|
}
|
||||||
|
|
||||||
|
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_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
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
add_arg()
|
||||||
|
{
|
||||||
|
[ "$1" ] || return 1
|
||||||
|
if [ "$args" ]; then
|
||||||
|
args="$args $1"
|
||||||
|
else
|
||||||
|
args=$1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
add_post_arg() {
|
add_post_arg()
|
||||||
[ -z "$1" ] && return 1
|
{
|
||||||
if [ "$post_args" ]; then
|
[ -z "$1" ] && return 1
|
||||||
post_args="$post_args $1"
|
if [ "$post_args" ]; then
|
||||||
else
|
post_args="$post_args $1"
|
||||||
post_args=$1
|
else
|
||||||
fi
|
post_args=$1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
check_cmd() {
|
check_cmd()
|
||||||
if [ -z "$command" ]; then
|
{
|
||||||
command=${2:-$1}; eval ${3:-${2:-$1}}=1
|
if [ -z "$command" ]; then
|
||||||
elif bool $do_post; then
|
command=${2:-$1}; eval ${3:-${2:-$1}}=1
|
||||||
add_post_arg ${1}
|
elif bool $do_post; then
|
||||||
else
|
add_post_arg ${1}
|
||||||
finished=1
|
else
|
||||||
fi
|
finished=1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
parse_args() {
|
parse_args()
|
||||||
case $1 in
|
{
|
||||||
-d|*-debug|d)
|
case $1 in
|
||||||
unset refresh_cmd; debug=echo\ $me\_debug: ;;
|
-d|*-debug|d)
|
||||||
|
unset refresh_cmd; debug=echo\ $me\_debug: ;;
|
||||||
|
|
||||||
-p|-*-post|p)
|
-p|-*-post|p)
|
||||||
unset finished do_std do_exec; do_post=1 ;;
|
unset finished do_standard do_exec; do_post=1 ;;
|
||||||
|
|
||||||
-c|*-center|c|-t|*-tile*|t|-f|*-full|f)
|
-c|*-center|c|-t|*-tile*|t|-f|*-full|f)
|
||||||
case $command in
|
case $command in
|
||||||
do_std|do_generate|do_bsetroot)
|
do_standard|do_generate|do_bsetroot)
|
||||||
finished=1 ;;
|
finished=1 ;;
|
||||||
do_exec)
|
do_exec)
|
||||||
if ! bool $got_fcmd; then
|
if ! bool $got_fcmd; then
|
||||||
add_arg $1 args; got_fcmd=1
|
add_arg $1 args; got_fcmd=1
|
||||||
else
|
else
|
||||||
finished=1
|
finished=1
|
||||||
fi ;;
|
fi ;;
|
||||||
*)
|
*)
|
||||||
add_arg $1; do_std=1; command=do_std
|
add_arg $1; do_standard=1; command=do_standard
|
||||||
esac ;;
|
esac ;;
|
||||||
|
|
||||||
-a|*-app|a|-e|*-exec|e)
|
-a|*-app|a|-e|*-exec|e)
|
||||||
check_cmd "do_exec" ;;
|
check_cmd "do_exec" ;;
|
||||||
|
|
||||||
-mod|-gradient|-solid|-display)
|
-mod|-gradient|-solid|-display)
|
||||||
check_cmd "do_bsetroot" && add_arg $1 ;;
|
check_cmd "do_bsetroot" && add_arg $1 ;;
|
||||||
|
|
||||||
-g|*-generate*|g)
|
-g|*-generate*|g)
|
||||||
check_cmd $1 "do_generate" ;;
|
check_cmd $1 "do_generate" ;;
|
||||||
|
|
||||||
-v|*-version|v)
|
-v|*-version|v)
|
||||||
[ -z "$command" ] && quit 0 $me $version $copyright ;;
|
[ -z "$command" ] && quit 0 $me $version $copyright ;;
|
||||||
|
|
||||||
-h|*-help|h)
|
-h|*-help|h)
|
||||||
[ -z "$command" ] && help_msg ;;
|
[ -z "$command" ] && help_msg ;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
bool $finished && return 1
|
bool $finished && return 1
|
||||||
|
|
||||||
case $1 in -*)
|
case $1 in -*)
|
||||||
bool $do_exec || bool $do_bsetroot || bool $do_post || help_msg 1
|
bool $do_exec || bool $do_bsetroot || bool $do_post || help_msg 1
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if bool $do_std || bool $do_exec || bool $do_bsetroot || bool $do_generate; then
|
if bool $do_standard || bool $do_exec || bool $do_bsetroot || bool $do_generate; then
|
||||||
add_arg $1
|
add_arg $1
|
||||||
elif bool $do_post; then
|
elif bool $do_post; then
|
||||||
add_post_arg $1
|
add_post_arg $1
|
||||||
else
|
else
|
||||||
add_arg $1; command=do_std; finished=1
|
add_arg $1; command=do_standard; finished=1
|
||||||
fi
|
fi
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
[ -z "$*" ] && help_msg 1
|
[ -z "$*" ] && help_msg 1
|
||||||
|
|
|
@ -137,38 +137,39 @@ void bsetroot::setPixmapProperty(int screen, Pixmap pixmap) {
|
||||||
unsigned long length, after;
|
unsigned long length, after;
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
int mode = PropModeAppend;
|
int mode = PropModeAppend;
|
||||||
|
int emode = PropModeAppend;
|
||||||
const ScreenInfo *screen_info = getScreenInfo(screen);
|
const ScreenInfo *screen_info = getScreenInfo(screen);
|
||||||
|
|
||||||
if (rootpmap_id == None) {
|
if (rootpmap_id == None) {
|
||||||
rootpmap_id = XInternAtom(getXDisplay(), "_XROOTPMAP_ID", True);
|
rootpmap_id = XInternAtom(getXDisplay(), "_XROOTPMAP_ID", True);
|
||||||
esetroot_id = XInternAtom(getXDisplay(), "_ESETROOT_PMAP_ID", True);
|
esetroot_id = XInternAtom(getXDisplay(), "ESETROOT_PMAP_ID", True);
|
||||||
}
|
}
|
||||||
|
|
||||||
XGrabServer(getXDisplay());
|
XGrabServer(getXDisplay());
|
||||||
|
|
||||||
/* Clear out the old pixmap */
|
// Clear out the old pixmap?
|
||||||
XGetWindowProperty(getXDisplay(), screen_info->getRootWindow(),
|
XGetWindowProperty(getXDisplay(), screen_info->getRootWindow(),
|
||||||
rootpmap_id, 0L, 1L, False, AnyPropertyType,
|
rootpmap_id, 0L, 1L, False, AnyPropertyType,
|
||||||
&type, &format, &length, &after, &data);
|
&type, &format, &length, &after, &data);
|
||||||
|
|
||||||
if ((type == XA_PIXMAP) && (format == 32) && (length == 1)) {
|
if ((type == XA_PIXMAP) && (format == 32) && (length == 1)) {
|
||||||
unsigned char* data_esetroot = 0;
|
XKillClient(getXDisplay(), *((Pixmap *) data));
|
||||||
XGetWindowProperty(getXDisplay(), screen_info->getRootWindow(),
|
XSync(getXDisplay(), False);
|
||||||
esetroot_id, 0L, 1L, False, AnyPropertyType,
|
mode = PropModeReplace;
|
||||||
&type, &format, &length, &after, &data);
|
|
||||||
if (data && data_esetroot && *((Pixmap *) data)) {
|
|
||||||
XKillClient(getXDisplay(), *((Pixmap *) data));
|
|
||||||
XSync(getXDisplay(), False);
|
|
||||||
mode = PropModeReplace;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear out the old esetroot pixmap?
|
||||||
|
XGetWindowProperty(getXDisplay(), screen_info->getRootWindow(),
|
||||||
|
esetroot_id, 0L, 1L, False, AnyPropertyType,
|
||||||
|
&type, &format, &length, &after, &data);
|
||||||
|
if ((type == XA_PIXMAP) && (format == 32) && (length == 1))
|
||||||
|
emode = PropModeReplace;
|
||||||
|
|
||||||
if (pixmap) {
|
if (pixmap) {
|
||||||
XChangeProperty(getXDisplay(), screen_info->getRootWindow(),
|
XChangeProperty(getXDisplay(), screen_info->getRootWindow(),
|
||||||
rootpmap_id, XA_PIXMAP, 32, mode,
|
rootpmap_id, XA_PIXMAP, 32, mode,
|
||||||
(unsigned char *) &pixmap, 1);
|
(unsigned char *) &pixmap, 1);
|
||||||
XChangeProperty(getXDisplay(), screen_info->getRootWindow(),
|
XChangeProperty(getXDisplay(), screen_info->getRootWindow(),
|
||||||
esetroot_id, XA_PIXMAP, 32, mode,
|
esetroot_id, XA_PIXMAP, 32, emode,
|
||||||
(unsigned char *) &pixmap, 1);
|
(unsigned char *) &pixmap, 1);
|
||||||
} else {
|
} else {
|
||||||
XDeleteProperty(getXDisplay(), screen_info->getRootWindow(),
|
XDeleteProperty(getXDisplay(), screen_info->getRootWindow(),
|
||||||
|
@ -215,6 +216,9 @@ void bsetroot::solid(void) {
|
||||||
Pixmap pixmap = XCreatePixmap(getXDisplay(),
|
Pixmap pixmap = XCreatePixmap(getXDisplay(),
|
||||||
screen_info->getRootWindow(),
|
screen_info->getRootWindow(),
|
||||||
8, 8, DefaultDepth(getXDisplay(), screen));
|
8, 8, DefaultDepth(getXDisplay(), screen));
|
||||||
|
|
||||||
|
XSetForeground(getXDisplay(), DefaultGC(getXDisplay(), screen),
|
||||||
|
c.getPixel());
|
||||||
XFillRectangle(getXDisplay(), pixmap, DefaultGC(getXDisplay(), screen),
|
XFillRectangle(getXDisplay(), pixmap, DefaultGC(getXDisplay(), screen),
|
||||||
0, 0, 8, 8);
|
0, 0, 8, 8);
|
||||||
|
|
||||||
|
@ -353,8 +357,8 @@ void bsetroot::usage(int exit_code) {
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
char *display_name = (char *) 0;
|
char *display_name = (char *) 0;
|
||||||
|
|
||||||
i18n->openCatalog("blackbox.cat");
|
NLSInit("openbox.cat");
|
||||||
|
|
||||||
for (int i = 1; i < argc; i++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
if (! strcmp(argv[i], "-display")) {
|
if (! strcmp(argv[i], "-display")) {
|
||||||
// check for -display option
|
// check for -display option
|
||||||
|
|
Loading…
Reference in a new issue