#!/bin/bash # # Script: quickfont # # Version: 0.3 # # # Author: DKD (dale_d at telusplanet dot net) # Thanks to darkbolt and sharth! # # Purpose: To save me having to type in all the commands # to install new TT Fonts manually each time. # # Usage: quickfont -d /path/to/fontdir # # Assumptions: python, head, tail, and grep are in your $PATH # # Warranty: This script was wrtten for my personal use and comes with # absolutely no warranty. In fact it may even damage your # system although that is unlikely. Use at your own risk. # # I disclaim all warranties with regard to the script provided herein, # including all implied warranties of merchantability and fitness # for any particular purpose. In no event shall I be liable for # any special, indirect or consequential damages or any damages # whatsoever resulting from loss of use, data or profits, whether in # an action of contract, negligence or other tortuous action, # arising out of or in connection with the use or performance # of this script. # # License: GPL - http://www.gnu.org/licenses/gpl.txt # # Grab the complete paths to xset, ttmkfdir, and mkfontalias.py # in case they caren't in the uer's $PATH (i.e. logged in as root). # XSET=$(which xset) TTMKFDIR=$(which ttmkfdir) MKFONTALIAS=$(which mkfontalias.py) # # get the font directory to add # while getopts ":d:" opt; do case $opt in d) DIR_NAME="$OPTARG" ;; \?) echo 'USAGE: quickfont -d /path/to/fontdir' exit 1 esac done # # Check to make sure that the $DIR_NAME is not blank # and exit the script if it is. # if [ -z $DIR_NAME ]; then echo "" echo "You did not specify a directory. The correct syntax is:" echo "quickfonts -d /path/to/fontdir" echo "" exit 1 fi # # Check to make sure that the $DIR_NAME is a valid path and cd to it otherwise # exit the script # if [ ! -e $DIR_NAME ]; then echo "" echo "You entered an invalid path." echo "$DIR_NAME does not exist." echo "" exit 1 fi cd $DIR_NAME # # clean up old font dir, scale, alias files # if [ -e "encodings.dir" ]; then rm encodings.dir fi if [ -e "fonts.alias" ]; then rm fonts.alias fi if [ -e "fonts.dir" ]; then rm fonts.dir fi if [ -e "fonts.scale" ]; then rm fonts.scale fi # # make the new font dir, scale, alias files # echo "quickfont: Starting font installation:" $TTMKFDIR -o fonts.scale echo "Processing fonts..." head -n 1 fonts.scale > fonts.dir tail -n +2 fonts.scale | tac >> fonts.dir cp fonts.dir fonts.scale echo "Making font aliases..." $MKFONTALIAS grep 'iso8859-1"' fonts.alias > new.alias mv new.alias fonts.alias # # modify the path to xset for your system if necessary # echo "Refreshing X Font Cache..." $XSET +fp $DIR_NAME * * Display some touchy-feely stuff * echo "Completed!" echo "" echo "Your new fonts are installed and should appear in your X apps now." echo "" echo "NOTE: for Gnome and KDE, you may need to run additional" echo "commands... refer to the appropriate documentation." echo "" echo "NOTE: With Gnome it is easiest to keep all your TT Fonts in one" echo "place and make a symlink in your home directory to it named ~/.fonts" echo "" echo "!!!!!! IMPORTANT !!!!!!" echo "Unless you are just updating a pre-existing font directory," echo "you must add the following line to your /etc/X11/XF86Config" echo "file in the \"Section \"Files\"\" or the next time you restart" echo "X, the new fonts will not display." echo "" echo "FontPath \"$DIR_NAME\"" echo ""