home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- # update-fonts-scale
- # compiles fonts.scale files for X font directories
- # see mkfontdir(1) for a description of the format of fonts.scale files
- # Copyright 1999 Branden Robinson. Licensed under the GNU GPL, version 2.
-
- if [ $# -eq 0 ]; then
- echo "$0: one or more font directories must be provided."
- exit 1
- fi
-
- while [ "$1" ]; do
- # try to be clever about the arguments
- if [ "$(echo $1 | cut -c1)" = "/" ]; then
- # absolute path to X font directory was provided
- XDIR=$1
- ETCDIR=/etc/X11/fonts/$(basename $XDIR)
- if [ "$XDIR" = "$ETCDIR" ]; then
- # they gave us an /etc directory as the argument
- echo "$0: path to X font directory must be used."
- exit 1
- fi
- else
- # assume they just gave us the basename
- XDIR=/usr/lib/X11/fonts/$1
- ETCDIR=/etc/X11/fonts/$1
- fi
- for dir in $XDIR $ETCDIR; do
- valid=yes
- if [ ! -d $dir ]; then
- echo "$0: $dir does not exist or is not a directory."
- valid=
- fi
- done
- if [ "$valid" ]; then
- if [ -e $XDIR/fonts.scale ]; then
- # backup old fonts.scale file in case we are interrupted
- cp $XDIR/fonts.scale $XDIR/fonts.scale.update-backup
- fi
- # are there any files to process?
- if [ "$(echo $ETCDIR/*.scale)" != "$ETCDIR/*.scale" ]; then
- for file in $ETCDIR/*.scale; do
- tail +2 $file >> $XDIR/fonts.scale.update-tmp
- done
- cat $XDIR/fonts.scale.update-tmp | wc -l | tr -d '[:blank:]' > $XDIR/fonts.scale
- cat $XDIR/fonts.scale.update-tmp >> $XDIR/fonts.scale
- rm $XDIR/fonts.scale.update-tmp
- fi
- fi
- shift
- done
-
- if [ -e $XDIR/fonts.scale.update-backup ]; then
- # we are done, remove the backup file
- rm $XDIR/fonts.scale.update-backup
- fi
-
- exit
-