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
86
util/bsetbg
86
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,34 +54,38 @@ 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
|
[ "$1" ] && rc=$1 && shift 1
|
||||||
[ "$*" ] && echo -e $*
|
[ "$*" ] && echo -e $*
|
||||||
exit ${rc:-0}
|
exit ${rc:-0}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool() {
|
bool()
|
||||||
|
{
|
||||||
case $1 in
|
case $1 in
|
||||||
[yY][eE][sS]|1|[yY]|[tT][rR][uU][eE]|[oO][nN]) : ;;
|
[yY][eE][sS]|1|[yY]|[tT][rR][uU][eE]|[oO][nN]) : ;;
|
||||||
*) return 1 ;;
|
*) return 1 ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
check_exe_in_path() {
|
check_exe_in_path()
|
||||||
|
{
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
return 1
|
return 1
|
||||||
elif [ -x "$(which $1 2>/dev/null)" ]; then
|
elif [ -x "$(which $1 2>/dev/null)" ]; then
|
||||||
|
@ -91,7 +97,8 @@ check_exe_in_path() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
help_msg() {
|
help_msg()
|
||||||
|
{
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
$me $version $copyright
|
$me $version $copyright
|
||||||
|
|
||||||
|
@ -119,7 +126,8 @@ EOF
|
||||||
quit ${1:-0}
|
quit ${1:-0}
|
||||||
}
|
}
|
||||||
|
|
||||||
get_apps() {
|
get_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
|
||||||
eval center_cmd=\$$a\_center_cmd
|
eval center_cmd=\$$a\_center_cmd
|
||||||
|
@ -138,7 +146,8 @@ get_apps() {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
do_generate() {
|
do_generate()
|
||||||
|
{
|
||||||
echo -e "# created by $me $version on $(date)\n#"
|
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 "# seting NO_EXEC to a boolean value (eg true/false) will cause $me"
|
||||||
echo -e "# to never modify the root window\n#"
|
echo -e "# to never modify the root window\n#"
|
||||||
|
@ -192,7 +201,8 @@ do_generate() {
|
||||||
quit 0
|
quit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
do_bsetroot() {
|
do_bsetroot()
|
||||||
|
{
|
||||||
if check_exe_in_path bsetroot; then
|
if check_exe_in_path bsetroot; then
|
||||||
read_config
|
read_config
|
||||||
|
|
||||||
|
@ -208,7 +218,8 @@ do_bsetroot() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
do_std() {
|
do_standard()
|
||||||
|
{
|
||||||
[ -z "$1" ] && help_msg 1
|
[ -z "$1" ] && help_msg 1
|
||||||
|
|
||||||
bool $noconfig || read_config
|
bool $noconfig || read_config
|
||||||
|
@ -228,7 +239,8 @@ do_std() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
do_exec() {
|
do_exec()
|
||||||
|
{
|
||||||
[ "$#" -lt 3 ] && help_msg 3
|
[ "$#" -lt 3 ] && help_msg 3
|
||||||
|
|
||||||
bool $noconfig || read_config
|
bool $noconfig || read_config
|
||||||
|
@ -277,7 +289,8 @@ do_exec() {
|
||||||
exec_img_command $do_this $file
|
exec_img_command $do_this $file
|
||||||
}
|
}
|
||||||
|
|
||||||
get_img_command() {
|
get_img_command()
|
||||||
|
{
|
||||||
case $1 in
|
case $1 in
|
||||||
*-full|-f|f) type=full; do_this="$full_cmd" ;;
|
*-full|-f|f) type=full; do_this="$full_cmd" ;;
|
||||||
*-tile|-t|t) type=tile; do_this="$tile_cmd" ;;
|
*-tile|-t|t) type=tile; do_this="$tile_cmd" ;;
|
||||||
|
@ -286,7 +299,8 @@ get_img_command() {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
check_img_command() {
|
check_img_command()
|
||||||
|
{
|
||||||
if check_exe_in_path $1; then
|
if check_exe_in_path $1; then
|
||||||
do_this="$*"
|
do_this="$*"
|
||||||
rc=0
|
rc=0
|
||||||
|
@ -305,7 +319,8 @@ check_img_command() {
|
||||||
return $rc
|
return $rc
|
||||||
}
|
}
|
||||||
|
|
||||||
exec_img_command() {
|
exec_img_command()
|
||||||
|
{
|
||||||
unset rc
|
unset rc
|
||||||
command=$*
|
command=$*
|
||||||
|
|
||||||
|
@ -329,14 +344,16 @@ exec_img_command() {
|
||||||
return $rc
|
return $rc
|
||||||
}
|
}
|
||||||
|
|
||||||
log_cmd() {
|
log_cmd()
|
||||||
|
{
|
||||||
bool $LOG_LAST_CMD || return 1
|
bool $LOG_LAST_CMD || return 1
|
||||||
[ "$debug" ] && return 1
|
[ "$debug" ] && return 1
|
||||||
echo -e "$prev_cmd\n$*" >$last_cmd_file
|
echo -e "$prev_cmd\n$*" >$last_cmd_file
|
||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
read_config() {
|
read_config()
|
||||||
|
{
|
||||||
[ -f $config ] || return 1
|
[ -f $config ] || return 1
|
||||||
|
|
||||||
if bool $read_config; then
|
if bool $read_config; then
|
||||||
|
@ -357,24 +374,30 @@ read_config() {
|
||||||
bool $LOG_LAST_CMD && prev_cmd=$(tail -n 1 $last_cmd_file 2>/dev/null)
|
bool $LOG_LAST_CMD && prev_cmd=$(tail -n 1 $last_cmd_file 2>/dev/null)
|
||||||
}
|
}
|
||||||
|
|
||||||
check_no_exec() {
|
check_no_exec()
|
||||||
|
{
|
||||||
bool $NO_EXEC &&
|
bool $NO_EXEC &&
|
||||||
quit 0 "$p no_exec mode. the root window will not be modified."
|
quit 0 "$p no_exec mode. the root window will not be modified."
|
||||||
}
|
}
|
||||||
|
|
||||||
post_command() {
|
post_command()
|
||||||
|
{
|
||||||
if [ -n "$POST_COMMAND" -a "$rc" -le 0 ]; then
|
if [ -n "$POST_COMMAND" -a "$rc" -le 0 ]; then
|
||||||
if [ -n "$debug" ]; then
|
if [ -n "$debug" ]; then
|
||||||
$debug "running post_command: $POST_COMMAND $post_args"
|
$debug "running post_command: $POST_COMMAND $post_args"
|
||||||
else
|
else
|
||||||
$POST_COMMAND $post_args 2>/dev/null; erc=$?
|
post_command_output=$($POST_COMMAND $post_args 2>&1); erc=$?
|
||||||
[ "$erc" -gt 0 ] &&
|
if [ "$erc" -gt 0 ]; then
|
||||||
echo "$p post-command '$POST_COMMAND $post_args' exited with status $erc"
|
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
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
add_arg() {
|
add_arg()
|
||||||
|
{
|
||||||
[ "$1" ] || return 1
|
[ "$1" ] || return 1
|
||||||
if [ "$args" ]; then
|
if [ "$args" ]; then
|
||||||
args="$args $1"
|
args="$args $1"
|
||||||
|
@ -383,7 +406,8 @@ add_arg() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
add_post_arg() {
|
add_post_arg()
|
||||||
|
{
|
||||||
[ -z "$1" ] && return 1
|
[ -z "$1" ] && return 1
|
||||||
if [ "$post_args" ]; then
|
if [ "$post_args" ]; then
|
||||||
post_args="$post_args $1"
|
post_args="$post_args $1"
|
||||||
|
@ -392,7 +416,8 @@ add_post_arg() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
check_cmd() {
|
check_cmd()
|
||||||
|
{
|
||||||
if [ -z "$command" ]; then
|
if [ -z "$command" ]; then
|
||||||
command=${2:-$1}; eval ${3:-${2:-$1}}=1
|
command=${2:-$1}; eval ${3:-${2:-$1}}=1
|
||||||
elif bool $do_post; then
|
elif bool $do_post; then
|
||||||
|
@ -402,17 +427,18 @@ check_cmd() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
parse_args() {
|
parse_args()
|
||||||
|
{
|
||||||
case $1 in
|
case $1 in
|
||||||
-d|*-debug|d)
|
-d|*-debug|d)
|
||||||
unset refresh_cmd; debug=echo\ $me\_debug: ;;
|
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
|
||||||
|
@ -421,7 +447,7 @@ parse_args() {
|
||||||
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)
|
||||||
|
@ -446,12 +472,12 @@ parse_args() {
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
|
||||||
XGetWindowProperty(getXDisplay(), screen_info->getRootWindow(),
|
|
||||||
esetroot_id, 0L, 1L, False, AnyPropertyType,
|
|
||||||
&type, &format, &length, &after, &data);
|
|
||||||
if (data && data_esetroot && *((Pixmap *) data)) {
|
|
||||||
XKillClient(getXDisplay(), *((Pixmap *) data));
|
XKillClient(getXDisplay(), *((Pixmap *) data));
|
||||||
XSync(getXDisplay(), False);
|
XSync(getXDisplay(), False);
|
||||||
mode = PropModeReplace;
|
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,7 +357,7 @@ 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")) {
|
||||||
|
|
Loading…
Reference in a new issue