[comp.windows.x] Shell script

rlk@THINK.COM (Robert L. Krawitz) (10/22/89)

Here's a shell script I wrote to set my screen background to something
interesting without having to remember all the details about where a
particular picture lives, what program needs to be run, whether a
particular file is compressed, or whatnot.  Enjoy.

____________________________________________________________________________
# This is a shell archive.  Remove anything before this line, then
# unpack it by saving it in a file and typing "sh file".  (Files
# unpacked will be owned by you and have default permissions.)
#
# This archive contains:
# xrt

echo x - xrt
cat > "xrt" << '//E*O*F xrt//'
#!/bin/sh

# xrt -- set screen background or list available options
# xrt <name> -- set screen background to pattern named <name>
# xrt -l -- list all available pictures
# Written by Robert Krawitz <rlk@think.com> 10/22/89
# Things to do:
#	1)  Import XPICPATH variable
#	2)  Allow -v option for verbose information

picdir='/usr/lib/X11/pictures /usr/lib/X11/poskbitmaps'
dumpxtn=dmp
bitmapxtn=xbm
compressxtn=Z

if test $1x = -lx; then
  (for dir in $picdir
    do
      ls $dir;
    done)\
  |awk -F. "{
	     if (\$NF ~ /$dumpxtn|$bitmapxtn/)
	     {
		 for (i = 1; i <= (NF-1); i++)
	       {
		 printf \"%s\", \$i
		 if (i < (NF-1)) printf \"%s\", FS
	       }
		printf \"\\n\"
	     }
	     else if (\$NF ~ /$compressxtn/ && (\$(NF-1) ~ /$dumpxtn|$bitmapxtn/))
	     {
	       for (i = 1; i <= (NF-2); i++)
	       {
		 printf \"%s\", \$i
		 if (i < (NF-2)) printf \"%s\", FS
	       }
		printf \"\\n\"
	     }
	     }" |sort|uniq;
else
  for dir in $picdir
    do
    if test -r ${dir}/$1.${dumpxtn}.${compressxtn}; then
      zcat ${dir}/$1.$dumpxtn | xroot;
      exit 0;
    elif test -r ${dir}/$1.${dumpxtn}; then
      cat ${dir}/$1.$dumpxtn | xroot;
      exit 0;
    elif test -r ${dir}/$1.${bitmapxtn}.${compressxtn}; then
      zcat ${dir}/$1.$bitmapxtn > /tmp/xbitmap$$;
      xsetroot -bitmap /tmp/xbitmap$$;
      exit 0;
    elif test -r ${dir}/$1.${bitmapxtn}; then
      xsetroot -bitmap ${dir}/$1.$bitmapxtn;
      exit 0;
    fi
  done
fi
exit 1
//E*O*F xrt//

exit 0

ames >>>>>>>>>  |	Robert Krawitz <rlk@think.com>	245 First St.
bloom-beacon >  |think!rlk	(postmaster)		Cambridge, MA  02142
harvard >>>>>>  .	Thinking Machines Corp.		(617)876-1111

kinzler@iuvax.cs.indiana.edu (Stephen Kinzler) (10/22/89)

Written by rlk@THINK.COM in news:comp.windows.x
---------- "Shell script" ----------
> Here's a shell script I wrote to set my screen background to something
> interesting without having to remember all the details about where a
> particular picture lives, what program needs to be run, whether a
> particular file is compressed, or whatnot.  Enjoy.

Here's another version of something similar.  If you have "jot", it'll
give you a random background screen by default.

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  xposk xposk.1
# Wrapped by kinzler@iuvax on Sun Oct 22 10:16:35 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'xposk' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xposk'\"
else
echo shar: Extracting \"'xposk'\" \(831 characters\)
sed "s/^X//" >'xposk' <<'END_OF_FILE'
X#! /bin/sh
X
Xposkdir=/install/X/poskbitmaps
X
X# xposk - set X root window background to a poskbitmap
X# Stephen Kinzler, kinzler@iuvax.cs.indiana.edu, July 1989
X
XPATH=/usr/local/bin:/usr/ucb:/bin:/usr/bin:/usr/bin/X11:/usr/new; export PATH
Xcd $poskdir
X
Xtmp=/tmp/`basename $0`$$
Xtrap "rm -f $tmp" 0 1 2 13 15
X
Xcase "$1" in
X-l)	ls | sed -n 's/\.xbm.*//p'		# list available bitmaps
X	exit;;
X
X'')	ls | grep .xbm > $tmp			# pick a random bitmap
X	num=`jot -r 1 1 \`wc -l < $tmp\``
X	set `sed -n ${num}p $tmp` .xbm
Xesac						# else use specified bitmap
X
Xset `echo "$1"*` x				# expand partial bitmap names
X
Xcase "$1" in					# handle compressed bitmaps
X*.xbm.Z)	zcat "$1" > $tmp && file=$tmp;;
X*.xbm)		file="$1"
Xesac
X
Xtest "$file" && {
X	echo "$1" | sed 's/\.xbm.*//'		# print bitmap name
X	xsetroot -bitmap "$file"		# set background to bitmap
X}
END_OF_FILE
if test 831 -ne `wc -c <'xposk'`; then
    echo shar: \"'xposk'\" unpacked with wrong size!
fi
chmod +x 'xposk'
# end of 'xposk'
fi
if test -f 'xposk.1' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xposk.1'\"
else
echo shar: Extracting \"'xposk.1'\" \(775 characters\)
sed "s/^X//" >'xposk.1' <<'END_OF_FILE'
X.TH XPOSK 1
X.SH NAME
Xxposk \- set X root window background to a poskbitmap
X.SH SYNOPSIS
X.B xposk
X[ -l | bitmap ]
X.SH DESCRIPTION
X.I Xposk
Xsets the root window of your X display to a randomly selected bitmap
Xfrom The Poskanzer Bitmap Collection,
Xor to any specified bitmap.
XPartial bitmap names are expanded and
Xthe name of the displayed bitmap is printed.
XBitmaps may be in compressed format (see
X.I compress(1)
X).
XBitmaps outside the
X.I poskbitmaps
Xdirectory may be specified with their absolute pathname.
XWith
X.I -l, xposk
Xlists the available bitmaps.
X.SH FILES
X/install/X/poskbitmaps	Poskanzer bitmap directory
X.SH AUTHOR
XStephen Kinzler, kinzler@iuvax.cs.indiana.edu, July 1989
X.SH "SEE ALSO"
Xxsetroot(1), bitmap(1), xphoon(1), xgranite(1),
X/install/X/poskbitmaps/README
END_OF_FILE
if test 775 -ne `wc -c <'xposk.1'`; then
    echo shar: \"'xposk.1'\" unpacked with wrong size!
fi
# end of 'xposk.1'
fi
echo shar: End of shell archive.
exit 0

madd@world.std.com (jim frost) (10/23/89)

In article <8910220448.AA15654@underprize.think.com> rlk@THINK.COM (Robert L. Krawitz) writes:
|Here's a shell script I wrote to set my screen background to something
|interesting without having to remember all the details about where a
|particular picture lives, what program needs to be run, whether a
|particular file is compressed, or whatnot.  Enjoy.

[YAPP - yet another program plug]

I have written a utility, xloadimage, which does both this and
displays images in a window.  It can handle several image formats,
including some color formats, can convert color images to monochrome,
reduce color image depth, and do other simple image manipulations.

While this utility is still in its youth, it is loosely based on
xbgsun which I wrote quite some time ago (and which had numerous
problems which I have tried to correct).  It appears to be quite
portable and reasonably fast.

Interested parties should email to madd@cs.bu.edu.

jim frost
software tool & die
madd@std.com

kinzler@iuvax.cs.indiana.edu (Stephen Kinzler) (10/23/89)

If you don't have "jot" on your system, you can use the "choose" program
from the comp.sources.unix archives (volume 2) instead.

Just change lines 19-20 of the xposk(1) script from:
	num=`jot -r 1 1 \`wc -l < $tmp\``
	set `sed -n ${num}p $tmp` .xbm
to:
	set `choose $tmp` .xbm

------------------------------------------------------------------------
|  ., >{~)  ['} /           Stephen Kinzler           \ + < : ~$[~{}== |
| % > %()}@! ' /     kinzler@iuvax.cs.indiana.edu      \ '}~{ >' & )<} |
| <@"??{.,'}  /    {ames,rutgers,att}!iuvax!kinzler     \ &"(&@+}<+;@) |
|  ])"}  +{) /   Indiana Univ Dept of Computer Science   \  @ }[^??^&. |
------------------------------------------------------------------------

raveling@isi.edu (Paul Raveling) (10/27/89)

In article <8910220448.AA15654@underprize.think.com>, rlk@THINK.COM
(Robert L. Krawitz) writes:
> Here's a shell script I wrote to set my screen background to something
> interesting without having to remember all the details about where a
> particular picture lives, what program needs to be run, whether a
> particular file is compressed, or whatnot.  Enjoy.

	... Looks a lot like our variant,

		"setback /images/color_mapped/some_image"

	except setback is a program with internalized logic to handle
	files in either compressed or uncompressed format.  However,
	it only handles file in Img format.  It'll also convert to
	dithered monochrome if you prefer.  Anyway it's on expo in
	contrib/Img.tar if you'd like to try it.


----------------
Paul Raveling
Raveling@isi.edu