|
楼主 |
发表于 2002-12-9 16:04:39
|
显示全部楼层
补充一下,还有一种方法,不用建 .Xresource 自己写一个脚本 gbrxvt
这样做的目的是为了达到 rxvt 的多语言切换
(代码其实是从 Mandrake 里抄来的 ):
[code:1]
SCRIPTNAME=`basename $0`
RXVT=/usr/bin/rxvt
if [ "$SCRIPTNAME" = "rxvt" -o "$SCRIPTNAME" = "rxvt.sh" -o "$SCRIPTNAME" = "xvt
" ]; then
if [ ! -z $LANGUAGE ]; then
locale=`echo $LANGUAGE | cut -d: -f1`
elif [ ! -z $LC_ALL ]; then
locale=$LC_ALL
elif [ ! -z $LC_CTYPE ]; then
locale=$LC_CTYPE
elif [ ! -z $LANG ]; then
locale=$LANG
fi
case $locale in
zh_TW*|zh_HK*)
SCRIPTNAME=crxvt
;;
zh_CN*)
SCRIPTNAME=gbrxvt
;;
ja*)
SCRIPTNAME=jrxvt
;;
ko*)
SCRIPTNAME=krxvt
;;
# unknown locale, ignore it
*)
SCRIPTNAME=rxvt
MENU=""
;;
esac
unset locale
fi
case $SCRIPTNAME in
crxvt)
LANG=zh_TW.Big5
LANGUAGE="zh_TW.Big5:zh_TW:zh"
ENC=big5
XA_FACE=ming
XA_FAMILY=default
XIM=xcin
# MENU="/etc/rxvt/rxvt-zh.menu;big5"
FNFONT="8x16"
FMFONT="-default-ming-medium-r-normal--16-*-*-*-c-160-big5-0"
_TITLE="Chinese"
;;
gbrxvt)
LANG=zh_CN.GB2312
LANGUAGE=zh_CN.GB2312:zh_CN:zh
ENC=gb
XA_FACE=simsun
XA_FAMILY=default
XIM=XSIM
FNFONT="8x16"
# MENU="/etc/rxvt/rxvt-zh.menu;gb"
FMFONT="-misc-Simsun-medium-r-normal--14-*-*-*-*-140-gb2312.1980-0"
_TITLE="Chinese"
;;
jrxvt)
LANG=ja_JP
LANGUAGE="ja_JP.EUC-JP:ja_JP.ujis:ja_JP:ja"
FNFONT="8x16"
ENC=eucj
XIM=kinput2
#MENU="/usr/share/rxvt/rxvt-ja;eucj"
_TITLE="Japanese"
;;
krxvt)
LANG=ko_KR
LANGUAGE="ko_KR.EUC-KR:ko_KR:ko"
ENC=kr
FNFONT="8x16"
XIM=Ami
#MENU="/usr/share/rxvt/rxvt-ko;kr"
_TITLE="Korean"
;;
# Locale other than jp / zh / ko, give ENC == noenc
rxvt | xvt)
RXVT="/usr/X11R6/bin/rxvt.bin"
unset $ENC
unset $XIM
if [ -e $HOME/.Xresources ] && grep -iq 'rxvt.*\<font\>' $HOME/.Xresources;
then
:
elif [ -e $HOME/.Xdefaults ] && grep -iq 'rxvt.*\<font\>' $HOME/.Xdefaults;
then
:
else
CHARSET=`locale charmap`
case "$CHARSET" in
ISO-8859-1) FNFONT="-*-fixed-medium-r-normal-*-*-140-75-75-*-*-iso8859-1
" ;;
ISO-8859-2) FNFONT="-*-fixed-medium-r-normal-*-*-140-75-75-*-*-iso8859-2
" ;;
# there is no bitmap font for iso-8859-3, which is deprecated in favor
# of utf-8, so we use the Adobe Courier Type1.
ISO-8859-3) FNFONT="-*-courier-medium-r-normal-*-*-140-75-75-*-*-iso8859
-3" ;;
ISO-8859-5) FNFONT="-*-fixed-medium-r-normal-*-*-140-75-75-*-*-iso8859-5
" ;;
ISO-8859-7) FNFONT="-*-fixed-medium-r-normal-*-*-140-75-75-*-*-iso8859-7
" ;;
ISO-8859-9) FNFONT="-*-fixed-medium-r-normal-*-*-140-75-75-*-*-iso8859-9
" ;;
ISO-8859-13) FNFONT="-*-fixed-medium-r-normal-*-*-140-75-75-*-*-iso8859-
13" ;;
ISO-8859-15) FNFONT="-*-fixed-medium-r-normal-*-*-140-75-75-*-*-iso8859-
15" ;;
# we don't provide a default monospaced font for cp1251 encoding...
# it is better to use xterm for it
# this font is very ugly, but at least it works
CP1251) FNFONT="-*-*-medium-r-normal-*-*-100-75-75-*-*-microsoft-cp1251"
;;
KOI8-R) FNFONT="-*-fixed-medium-r-normal-*-*-140-75-75-*-*-koi8-r" ;;
KOI8-U) FNFONT="-*-fixed-medium-r-normal-*-*-140-75-75-*-*-koi8-u" ;;
# other encodings don't work properly anyway with rxvt; xterm should be
# used instead.
*) FNFONT="-*-fixed-medium-r-normal-*-*-140-75-75-*-*-iso8859-15" ;
echo ""
echo "=============================================="
echo "WARNING!!"
echo ""
echo "rxvt is unable to display in $CHARSET encoding"
echo "you should use xterm instead"
echo "=============================================="
;;
esac
fi
;;
esac
export LANG LANGUAGE
FGCOLOR=lightgray
BGCOLOR=black
TITLE="$_TITLE RXVT ($LANG)"
ARGS=""
while [ -n "$1" ]; do
case $1 in
-km) shift
ENC=$1
;;
-im) shift
XIM=$1
;;
-fg) shift
FGCOLOR=$1
;;
-bg) shift
BGCOLOR=$1
;;
-T|-title) shift
TITLE=$1
;;
-menu) shift
MENU="$1"
;;
-nomenu)
MENU=""
;;
-fn) shift
FNFONT="$1"
;;
-fm) shift
FMFONT="$1"
;;
*)
ARGS="$ARGS $1"
;;
esac
shift
done
[ -n "$BGCOLOR" ] && ARGS="-bg $BGCOLOR $ARGS"
[ -n "$FGCOLOR" ] && ARGS="-fg $FGCOLOR $ARGS"
[ -n "$ENC" ] && ARGS="-km $ENC $ARGS"
if [ -n "$XIM" -a -n "$ENC" ]; then
ARGS="-im $XIM $ARGS"
export XMODIFIERS="@im=$XIM"
fi
# Alas! Dirty hack for font name containing spaces
# Is there any simpler solution??
if [ -n "$FNFONT" -a -n "$FMFONT" ]; then
exec $RXVT -T "$TITLE" -menu "$MENU" -fn "$FNFONT" -fm "$FMFONT" $ARGS
elif [ -n "$FNFONT" ]; then
exec $RXVT -T "$TITLE" -menu "$MENU" -fn "$FNFONT" $ARGS
elif [ -n "$FMFONT" ]; then
shift
done
[ -n "$BGCOLOR" ] && ARGS="-bg $BGCOLOR $ARGS"
[ -n "$FGCOLOR" ] && ARGS="-fg $FGCOLOR $ARGS"
[ -n "$ENC" ] && ARGS="-km $ENC $ARGS"
if [ -n "$XIM" -a -n "$ENC" ]; then
ARGS="-im $XIM $ARGS"
export XMODIFIERS="@im=$XIM"
fi
# Alas! Dirty hack for font name containing spaces
# Is there any simpler solution??
if [ -n "$FNFONT" -a -n "$FMFONT" ]; then
exec $RXVT -T "$TITLE" -menu "$MENU" -fn "$FNFONT" -fm "$FMFONT" $ARGS
elif [ -n "$FNFONT" ]; then
exec $RXVT -T "$TITLE" -menu "$MENU" -fn "$FNFONT" $ARGS
elif [ -n "$FMFONT" ]; then
exec $RXVT -T "$TITLE" -menu "$MENU" -fm "$FMFONT" $ARGS
else
exec $RXVT -T "$TITLE" -menu "$MENU" $ARGS
fi
[/code:1] |
|