#!/bin/sh # # language/font setting script for Window Maker # # by MANOME Tomonori # (rewriten slightly by judas@hell on Jan 27 2001 # -argument --nodef tries to change only font coding (limited!) # -much easier to add new font codings # -much harder to read code... # -argument --auto gets locale by itself, but does not override if some # coding is also given # -argument --locale=?? takes locale code (ja, sk, ...) # ) # # [Special Thanks To] # Korean fontset info from: # Byeong-Chan, Kim # Chae-yong Chong # Latin2 fontset info from: # Piotr Dembinski # Toni Bilic # Greek fontset info from: # Nikolaos Papagrigoriou # Quote bug fix info from: # Luke Kendall # Bug fix info for Korean font section from: # CHOI Junho VERSION="Version 0.5 1998/12/07" WDWRITE="wdwrite" WDREAD="wdread" PROGRAM=`basename $0` help_msg() { echo -e "\n"\ "$PROGRAM - font/language setting utility for Window Maker\n"\ "\n"\ "Usage: $VERSION\n"\ " $PROGRAM [--nodef] [--auto] " >/dev/stderr cat >/dev/stderr </dev/stderr exit 1 fi # # Nodef is supported only for elements of $NodefAble. # is_nodef_unable="" for i in $NodefUnable; do if test "$family" == "$i"; then if test -n "$nodef"; then # --nodef with one from $NodefUnable echo -e "\n"\ "Sorry, --nodef argument is not allowed for these font codings:\n"\ " $NodefUnable\n"\ "Run $PROGRAM without --nodef argument to set default fonts for your\n"\ "font coding.\n"\ "" >/dev/stderr exit 1 else is_nodef_unable="YES" break fi fi done # # The real work... # if test -z "$nodef"; then for i in $AllKeys; do if test -n "$is_nodef_unable"; then # japanese,... defaults tmp="$family$i" eval $i=${!tmp} else # rest, load defaults not_font="" for j in $NotFont; do if test "$i" == "$j"; then not_font="YES" break fi done if test -n "$not_font"; then # don't append coding (not default!) tmp="${family}$i" eval $i="${!tmp}" else # append coding tmp="Default$i" tmp1="${family}Coding" eval $i="${!tmp}${!tmp1}" fi fi done else echo -e "\n"\ "You used --nodef command line argument. You should note, that this\n"\ "works with these font codings only:\n"\ " $NodefAble\n"\ "You should not use it to change fonts from other font codings than\n"\ "those listed above. If your WindowMaker does not appear to find fonts,\n"\ "you should run $PROGRAM once again without --nodef argument." >/dev/stderr fi # # Ok, in the following, `i' will be the domain file name, # `j' is the actual key in that file we try to change... # for i in $DomainNames; do echo echo "Setting up $i domain file..." tmp="Domain$i" for j in ${!tmp}; do if test -n "$nodef"; then # --nodef, change coding only not_font="" for k in $NotFont; do if test "$k" == "$j"; then not_font="YES" break; fi done if test -n "$not_font"; then # don't append coding tmp1="${family}$j" eval $j=${!tmp1} else # append coding #TODO:make this funny sed script a lot smarter to let us make changes in font # lists, etc... (then we can enable --nodef for NodefUnable codings) #TODO:better (or at least any) check, whether wmaker is installed... tmp1="${family}Coding" eval $j=$($WDREAD $i $j | sed -e "s/\(^-.*-\).*-.*$/\1${!tmp1}/g") if test -z "${!j}"; then # failed, load default tmp2="Default$j" eval $j=${!tmp2} fi fi fi tmp1="$j=\"${!j}\"" # cosmetic length workaround if (( ${#tmp1} > 80 )); then tmp1=$(echo "${tmp1:0:76}...\"") fi echo "$tmp1" $WDWRITE $i $j \"${!j}\" done done echo