#!/bin/sh - PATH=/usr/local/bin:/usr/ucb:/usr/bsd:/bin:/usr/bin/X11:/usr/bin:/l/netpbm/bin export PATH # $Id: usermontage,v 1.8 2000/01/25 17:01:17 root Exp $ #DISPLAY=:0.0 # X server required for label font #export DISPLAY piconsdir=/l/picons/db/users/edu/indiana nopicon=/l/picons/db/misc/MISC/nothing/face.gif #trans=grey75 # background/transparent color #gargs="-transparent $trans" # ppmtogif(1) options trans=white # background/transparent color gargs= # ppmtogif(1) options maxco=128 # max # of colors, iff $gargs margs1="+frame -tiles_per_row $1 -borderwidth 0"\ " -background $trans " # montage(1) options margs2='-geometry 49x49+0+0 -font 5x7' # expand some to get 8-bit color # and fit in an 8-char label # usermontage - create a montage of picons of the given local users # Steve Kinzler, kinzler@cs.indiana.edu, Nov 95 case $# in 2) out="$2";; *) echo "usage: $0 columns { outfile.gif | - }" 1>&2; exit 1;; esac ############################################################################### # As far as I can tell, access to the X server is no longer # needed. I'll find out if I'm wrong the next time it runs # from cron. --robh 10/99 #case "`xset q 2> /dev/null`" in #'') echo "$0: cannot access X server ($DISPLAY)" 1>&2 # cat > /dev/null; exit 2;; #esac tmp=/tmp/mo$$ trap 'rm -fr $tmp $tmp.gif; exit 6' 1 2 13 15 mkdir $tmp || exit $? sed 's/[ ]*//' | sort -u | while read user do test -f "$piconsdir/$user/face.gif" && ln -s "$piconsdir/$user/face.gif" "$tmp/$user" && continue test -f "$piconsdir/$user/face.xbm" && ln -s "$piconsdir/$user/face.xbm" "$tmp/$user" && continue test -f "$nopicon" && ln -s "$nopicon" "$tmp/$user" done if test "`cd $tmp; ls | wc -l`" -le 0 then echo "$0: no picons found" 1>&2; exit 4 fi (cd $tmp; montage $margs1 $margs2 * $tmp.gif < /dev/null) if test ! -s $tmp.gif then echo "$0: montage creation failed" 1>&2; exit 5 fi #BEGIN kludge # Chop off extra pixel rows (2 per icon row) at the bottom of the # montage-generated gif. # Why are these here? They weren't in older versions of montage, I think. # kinzler, Tue Jan 25 10:45:50 EST 2000 width=` giftopnm < $tmp.gif | pnmfile | sed 's/ *by.*//; s/.* //'` height=`giftopnm < $tmp.gif | pnmfile | sed 's/.*by *//; s/ .*//'` height=`expr $height - $height / 51 \* 2` giftopnm < $tmp.gif | pnmcut 0 0 $width $height > $tmp.ppm ppmtogif < $tmp.ppm > $tmp.gif 2> /dev/null rm -f $tmp.ppm #END kludge case "$gargs" in ?*) case "$out" in -) giftopnm < $tmp.gif 2> /dev/null | ppmquant $maxco 2> /dev/null | ppmtogif $gargs 2> /dev/null;; *) giftopnm < $tmp.gif 2> /dev/null | ppmquant $maxco 2> /dev/null | ppmtogif $gargs > "$out" 2> /dev/null;; esac;; *) case "$out" in -) cat < $tmp.gif;; *) cat < $tmp.gif > "$out";; esac;; esac rm -fr $tmp $tmp.gif exit 0