Path: utzoo!attcan!uunet!ginosko!gem.mps.ohio-state.edu!tut.cis.ohio-state.edu!bloom-beacon!THINK.COM!rlk From: rlk@THINK.COM (Robert L. Krawitz) Newsgroups: comp.windows.x Subject: Shell script Message-ID: <8910220448.AA15654@underprize.think.com> Date: 22 Oct 89 04:48:58 GMT Sender: root@bloom-beacon.MIT.EDU Organization: The Internet Lines: 82 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 -- set screen background to pattern named # xrt -l -- list all available pictures # Written by Robert Krawitz 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 245 First St. bloom-beacon > |think!rlk (postmaster) Cambridge, MA 02142 harvard >>>>>> . Thinking Machines Corp. (617)876-1111