Skip to content

Commit

Permalink
made bsetbg try tempfile, then mktemp, and fall back to creating a .1…
Browse files Browse the repository at this point in the history
…213 file if nothing else works
  • Loading branch information
shaleh committed Feb 10, 2002
1 parent f5a1605 commit 8eb652c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
2 changes: 2 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Stuff TODO or On The Way(tm):
ADD: add _BLACKBOX_STYLE and _BLACKBOX_MENU atoms so that bbtools, bbconf, etc.
can get the current path to the style in use and menu.

ADD: subdirs in stylesmenu/dir will create a new submenu

CHANGE: when workspace name is greater than the width of its text area the
toolbar gets very ugly

Expand Down
31 changes: 20 additions & 11 deletions util/bsetbg
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ search_xv()
rm_tmpfiles()
{
[ -f $TMPFILE ] && rm -f $TMPFILE
[ -f $TMPFILE2 ] && rm -f $TMPFILE2
}


Expand All @@ -325,8 +324,6 @@ create_config()
echo "$NAME: $CONFIG not found, creating..."
esac

rm_tmpfiles

for app in $IMAGE_APPS; do
search_$app
done
Expand Down Expand Up @@ -354,10 +351,9 @@ create_config()
echo "DEFAULT=\"$DEFAULT\"" >> $CONFIG
echo >> $CONFIG

cat $TMPFILE | grep -v $APP > $TMPFILE2
cat "$TMPFILE2" >> $CONFIG
cat $TMPFILE | grep -v $APP >> $CONFIG

rm -f $TMPFILE $TMPFILE2
rm -f $TMPFILE

if [ -f $CONFIG ]; then
echo "$NAME: default configuration was created in $CONFIG."
Expand Down Expand Up @@ -512,7 +508,7 @@ check_image()
esac
esac

if [ ! -e "$IMAGE" ]; then
if [ ! -f "$IMAGE" ]; then
error_msg $NUM
else
IMAGE_EXISTS=yes
Expand Down Expand Up @@ -600,16 +596,29 @@ debug()
echo
}

create_tempfile() {
if `type tempfile 2>&1 >/dev/null`; then
THETMP=`tempfile --prefix=bsetbg`
elif `type mktemp 2>&1 >/dev/null`; then
THETMP=`mktemp -t bsetbg`
else
THETMP=/tmp/.bsetbg.$$
if [ -f $THETMP ]; then
rm -f $THETMP
chmod 600 $THETMP
fi
fi
TMPFILE=$THETMP
}

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=/tmp/bsetbg.1
TMPFILE2=/tmp/bsetbg.2
ARGUMENT=$1

create_tempfile

case `which grep 2>&1` in */*grep) : ;;
*)
Expand Down Expand Up @@ -696,4 +705,4 @@ case $1 in
fi
help_msg
fi
esac
esac

0 comments on commit 8eb652c

Please sign in to comment.