LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 2161|回复: 5

小弟的输入法调用的方法

[复制链接]
发表于 2005-3-7 10:10:37 | 显示全部楼层 |阅读模式
看了很多关于输入法调用的方法,大多数都是要改locale的,个人认为这个方法不是很好
下面我说一下我的方法
不用卸chinput,关iiim服务
首先更改 /etc/X11/xinit/xinitrc.d/xinput 文件
找到这个代码行
if [ -z "$XIM" ]; then
    case $tmplang in ( ar* | be* | ja* | ko* | th* | zh* | *_IN* )
改为
if [ -z "$XIM" ]; then
    case $tmplang in ( ar* | be* | ja* | ko* | th* | zh* | *_IN* | en* )
然后添加下面的代码
en*)
            if [ -x /usr/bin/fcitx ]; then
                    XIM="fcitx"
            fi
        ;;
添加的位置,打开文件就可以看到了,因为有很多类似的代码
scim的用户将代码改为
en*)
            if [ -x /usr/bin/scim ]; then
                    XIM="SCIM"
            fi
        ;;

如果用zh_CN locale的 就改 zh_CN *)的,把chinput改为fcitx
接着添加这个代码
fcitx)
        XIM_PROGRAM=fcitx
       ;;
scim的用户改为
SCIM)
        XIM_PROGRAM=scim
        XIM_ARGS="-d"
        ;;
这样之后scim用户就可以使用中文输入了
如果是fcitx用户还有最后一步
更改.fcitx/config 文件
原来为 显示字体=*
改为 显示字体=simsun(当然改为你喜欢的字体也可以,只要可以显示中文就可以了)
如果是用vi 打开应改是乱码,如果locale是en_US.utf-8 之类的
更改的就是文件第二行的代码

重启X就可以了
我用的是FC2 KDE,在KDE的所有程序都可以调用输入法
FC3用更好的调用方法,论坛里就有了,搜索一下,好像已经加精了
 楼主| 发表于 2005-3-7 10:11:53 | 显示全部楼层
附上我的xinput文件
#!/bin/bash
# Copyright (C) 1999 - 2004 Red Hat, Inc. All rights reserved. This
# copyrighted material is made available to anyone wishing to use, modify,
# copy, or redistribute it subject to the terms and conditions of the
# GNU General Public License version 2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# XIM( X Input Method ) script
#
# Original Korean support contributed by:
#        Won-kyu Park <wkpark@chem.skku.ac.kr>
#

oldterm=$TERM
unset TERM
# Load up the user and system locale settings
if [ -r /etc/profile.d/lang.sh ]; then
  . /etc/profile.d/lang.sh
fi
export TERM=$oldterm

tmplang="en_US"
#if test x$GDM_LANG != x ; then
#    tmplang=$GDM_LANG
if [ -n "$LC_ALL" ]; then
    tmplang=$LC_ALL
elif [ -n "$LC_CTYPE" ]; then
    tmplang=$LC_CTYPE
elif [ -n "$LANG" ]; then
    tmplang=$LANG
elif [ -r /etc/sysconfig/i18n ]; then
    . /etc/sysconfig/i18n
    tmplang=$LANG
fi

#
# check to see if the user has a preferred desktop
#

PREFERRED=

# runlevel 5 - checks which session manager it will load
# runlevel 3 - checks which desktop manager it will load
if [ -f /etc/sysconfig/desktop ]; then
# WARNING: This grep regex can be combined when someone has copious spare time.
if grep -q "GNOME" /etc/sysconfig/desktop 2>/dev/null || grep -q "\"\"" /etc/sysconfig/desktop 2>/dev/null; then
         # runlevel 5 with gdm - checks for $GDMSESSION and set the $PREFERRED
         if [ "$GDMSESSION" = "Default" ]; then
                 PREFERRED=gnome
         elif [ "$GDMSESSION" = "GNOME" ]; then
                 PREFERRED=gnome
         elif [ "$GDMSESSION" = "KDE" ]; then
                 PREFERRED=kde
         else
                 # applies if no env and runlevel 3
                 PREFERRED=gnome
         fi
elif grep -q "KDE" /etc/sysconfig/desktop 2>/dev/null; then

        if [ -z $1 -o "$1" = "default" ]; then
                 # applies if no arg passed by kdm and runlevel 3
                 PREFERRED=kde
        else  
                 # otherwise assign $PREFERRED from arg
                 PREFERRED=$1
        fi
fi
fi

if [ -z "$PREFERRED" ]; then

        GSESSION=gnome-session
        STARTKDE=startkde

        # by default, we run GNOME.
        if which "$GSESSION" > /dev/null 2>&1; then
                PREFERRED=gnome
        fi

        # if GNOME isn't installed, try KDE.
        if which "$STARTKDE" > /dev/null 2>&1; then
                PREFERRED=kde
        fi
fi


#
# check $XIM and set a default $XIM value.
#

# default to iiim if htt server is running
if [ -z "$XIM" ]; then
    case $tmplang in ( ar* | be* | ja* | ko* | th* | zh* | *_IN* | en* )
        if /sbin/service IIim status 2>/dev/null | /bin/grep -q pid ; then
          XIM=htt
        fi
        ;;
    esac

fi

# otherwise revert to legacy XIM client
if [ -z "$XIM" ]; then
    case $tmplang in  
        ja*)
# WARNING: This binary should be in /usr/bin, not in /usr/X11R6/bin, because
# /usr/X11R6/bin is strictly for software supplied as an official part of
# X11R6, not for random applications to drop files in.
            if [ -x /usr/X11R6/bin/xwnmo ]; then
                    XIM="_XWNMO"
            elif [ -x /usr/bin/uim-xim ]; then
                    XIM="uim"
# WARNING: This binary should be in /usr/bin, not in /usr/X11R6/bin, because
# /usr/X11R6/bin is strictly for software supplied as an official part of
# X11R6, not for random applications to drop files in.
            elif [ -x /usr/X11R6/bin/kinput2 ]; then
                    XIM="kinput2"
# WARNING: This binary should be in /usr/bin, not in /usr/X11R6/bin, because
# /usr/X11R6/bin is strictly for software supplied as an official part of
# X11R6, not for random applications to drop files in.
            elif [ -x /usr/X11R6/bin/skkinput ]; then
                    XIM="skkinput"
            fi
        ;;
        ko*)
            if [ -x /usr/bin/nabi ]; then
                    XIM="nabi"
            elif [ -x /usr/bin/ami ]; then
                    XIM="Ami"
            elif [ -x /usr/bin/hanIM ]; then
                    XIM="hanIM"
            fi
        ;;
        en*)
            if [ -x /usr/bin/fcitx ]; then
                    XIM="fcitx"
            fi
        ;;
        zh_CN*)
            if [ -x /usr/bin/chinput ]; then
                XIM="Chinput"
            fi
        ;;
        zh_TW*)
# WARNING: This binary should be in /usr/bin, not in /usr/X11R6/bin, because
# /usr/X11R6/bin is strictly for software supplied as an official part of
# X11R6, not for random applications to drop files in.
            if [ -x /usr/X11R6/bin/xcin ]; then
                XIM="xcin"
            fi
        ;;
    esac  
fi

#
# set a proper XIM program with respect to $XIM
#
if [ -z "$XIM_PROGRAM" ]; then
   case "$XIM" in
      Ami)
        case "$PREFERRED" in
           kde)
                if which wmami >/dev/null 2>&1 ; then
                        XIM_PROGRAM=wmami
                        XIM_ARGS="-wait"
                elif which ami >/dev/null 2>&1 ; then
                        XIM_PROGRAM=ami
                fi
                ;;
           *)
                if which ami >/dev/null 2>&1 ; then
                        XIM_PROGRAM=ami
                fi
                ;;
        esac
        ;;
      Chinput)
        XIM_PROGRAM=chinput
        ;;
      fcitx)
        XIM_PROGRAM=fcitx
        #XIM_ARGS="-d"
        ;;
      hanIM)
        if which hanIM >/dev/null 2>&1 ; then
                XIM_PROGRAM=hanIM
        fi
        ;;
      htt)
        XIM_PROGRAM=httx
        ;;
      kinput2)
        XIM_PROGRAM=kinput2
        if [ -z "$XIM_ARGS" ]; then
            if /usr/bin/cannaping 2>/dev/null ; then
                XIM_ARGS="-canna +kinput -xim"
            elif /sbin/service FreeWnn status 2>/dev/null | /bin/grep -q pid
            then
                XIM_ARGS="-wnn +kinput -xim"
            else
                XIM_ARGS="+kinput -xim"
            fi
        fi
        ;;
      nabi)
        XIM_PROGRAM=nabi
        ;;
      skkinput)
        XIM_PROGRAM=skkinput
        ;;
      uim)
        XIM_PROGRAM=uim-xim
        ;;
      _XWNMO)
        XIM_PROGRAM=xwnmo
        ;;
      xcin)
        XIM_PROGRAM=xcin  
        XIM_ARGS="-x xcin"
        ;;
      *)
        XIM_PROGRAM=/bin/true
        ;;
   esac
fi

# set default gtk IM module
if [ -z "$GTK_IM_MODULE" ]; then
   case "$XIM" in
     # htt)
#        GTK_IM_MODULE=iiim
#         ;;
       SCIM)
        GTK_IM_MODULE=xim
       QT_IM_MODULE=xim
       gnome-im-settings-daemon >/dev/null
         ;;
   esac
fi
[ -n "$GTK_IM_MODULE" ] && export GTK_IM_MODULE

# setup XMODIFIERS
[ -z "$XMODIFIERS" -a -n "$XIM" ] && export XMODIFIERS="@im=$XIM"

# execute XIM_PROGRAM
which "$XIM_PROGRAM" > /dev/null 2>&1 && LANG="$tmplang" "$XIM_PROGRAM" $XIM_ARGS &
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-3-7 23:06:25 | 显示全部楼层
小弟我有个问题,就是在firefox跟mozilla中调不出输入法,乖乖,也不是所有的gtk的都调不出来的,就这两个特别,不过幸亏小弟我用的是Konqueror
回复 支持 反对

使用道具 举报

发表于 2005-3-10 15:11:12 | 显示全部楼层
我按照楼主的办法完全操作成功.
感谢楼主!!!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-3-10 17:00:30 | 显示全部楼层
不会连firefox也没有问题吧,如果是难道是我RPWT
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-3-12 22:47:52 | 显示全部楼层
斑竹,小弟我的这篇可以加精吗?
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表