LinuxSir.cn,穿越时空的Linuxsir!

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

gentoo中文输入法自动加载解决办法!

[复制链接]
发表于 2004-10-20 15:57:52 | 显示全部楼层 |阅读模式
首先把下面的内容保存为xinputrc放到/usr/local/bin
  1. #!/bin/bash
  2. #Gentoo Linux Chinese Portage Group
  3. #[url]http://gentoo.linuxsir.cn[/url]
  4. #Author sunmoon1997
  5. #oct 20, 2004

  6. CONF="/etc/conf.d/xinput.conf"
  7. USER_CONF="${HOME}/.xinput.conf"
  8. PROGRAM=""
  9. XIM=""
  10. XIM_PROGRAM=""
  11. XMODIFIERS=""
  12. GTK_IM_MODULE=""
  13. QT_IM_MODULE=""

  14. unset realserver
  15. unset program
  16. unset parameters
  17. unset delay_time
  18. unset setxlocale

  19. if [ -f "$USER_CONF" ];then
  20. echo "using configure file $USER_CONF"
  21. source $USER_CONF
  22. else
  23. if [ -f "$CONF" ];then
  24.   source $CONF
  25.   echo "using configure file $CONF"
  26. else
  27.   echo "You SYSTEM miss the Xinput configure file \'$CONF\'"
  28.   exit 1
  29. fi
  30. fi

  31. if [ -z `type -p $program` ];then
  32. echo "$program cannot be found in \'$PATH\'"
  33.         exit 1
  34. fi

  35. PROGRAM=`awk -v i=$program 'BEGIN{print toupper(i)}'`
  36. XIMSERVER="$PROGRAM"

  37. if [ "x$realserver" != "x" ];then
  38.         XIMSERVER=`awk -v i=$realserver 'BEGIN{print toupper(i)}'`
  39.         echo "setting XIMSERVER to $XIMSERVER($realserver)"
  40. fi

  41. if [ "x$qt_im_module" = "x" ];then
  42.         QT_IM_MODULE="XIM"
  43.         echo "setting QT_IM_MODULE to XIM!"
  44. else
  45.         QT_IM_MODULE=`awk -v i=$qt_im_module 'BEGIN{print toupper(i)}'`
  46.         echo "setting QT_IM_MODULE to $QT_IM_MODULE"
  47. fi

  48. if [ "x$gtk_im_module" = "x" ];then
  49.         GTK_IM_MODULE="XIM"
  50.         echo "setting GTK_IM_MODULE to XIM!"
  51. else
  52.         GTK_IM_MODULE=`awk -v i=$gtk_im_module 'BEGIN{print toupper(i)}'`
  53.         echo "setting GTK_IM_MODULE to $GTK_IM_MODULE"
  54. fi

  55. if [ "$XIMSERVER" = "SKIM" ];then
  56.         echo "You should set realserver to scim!"
  57.         XIMSERVER="SCIM"
  58. fi

  59. XIM="$XIMSERVER"
  60. XIM_PROGRAM="$program"
  61. XIM_ARGS="$parameters"
  62. XMODIFIERS="@im=$XIMSERVER"

  63. export XIM XIM_PROGRAM XMODIFIERS GTK_IM_MODULE QT_IM_MODULE

  64. if [ "x$setxlocale" = "xtrue" ];then
  65.         LANGUAS=$XLANGUAS
  66.         LANG=$XLANG
  67.         LC_ALL=$XLC_ALL
  68.         LC_CTYPE=$XLC_CTYPE
  69.         LC_NUMERIC=$XLC_NUMERIC
  70.         LC_TIME=$XLC_TIME
  71.         LC_COLLATE=$XLC_COLLATE
  72.         LC_MONETARY=$XLC_MONETARY
  73.         LC_MESSAGES=$XLC_MESSAGES
  74.         LC_PAPER=$XLC_PAPER
  75.         LC_NAME=$XLC_NAME
  76.         LC_ADDRESS=$XLC_ADDRESS
  77.         LC_TELEPHONE=$XLC_TELEPHONE
  78.         LC_MEASUREMENT=$XLC_MEASUREMENT
  79.         LC_IDENTIFICATION=$XLC_IDENTIFICATION
  80.        
  81. export  LANGUAS LANG LC_ALL LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY
  82. export  LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION
  83. fi

  84. #start xim server
  85. if [ "x$delay_time" != "x" ]; then
  86. #spawn to new process with external shell
  87. bash -c "
  88. while [ x\`ps -C panel -o pid=\` == x ];
  89. do
  90.   sleep $delay_time
  91. done
  92. sleep $delay_time
  93. $XIM_PROGRAM $XIM_ARGS &
  94. " &
  95. else
  96. $XIM_PROGRAM $XIM_ARGS &
  97. fi
复制代码

再执行
#chmod a+x /usr/local/bin/xinputrc

给脚本加上可执行属性。
然后
#ln -s /usr/local/bin/xinputrc /etc/X11/xinit/xinitrc.d/100xinputrc

另外还需要一个配置文件xinput.conf, 默认的位置为/etc/conf.d/,个人配置文件为~/.xinput.conf
参考内容如下:
  1. #x input mathod program
  2. #fcitx, scim, skim
  3. #any of your favourite im.
  4. program="skim"

  5. #x input mathod program parameters
  6. #if you use fcitx, just set it to none.
  7. #scim & scim need a addtion option `d' to
  8. #tell them run as daemon.
  9. parameters="-d"

  10. #real xinput mothod server
  11. #some times the im program is not the real im server
  12. #so it's necessary to  tell 'xinputrc' who is the real sever.
  13. #but now 'xinputrc' know the skim's im server is scim
  14. #instead of skim, you can comment out the following line
  15. #it will be work too.
  16. realserver="scim"

  17. #delay a few seconds to load xinput mothod server
  18. #to prevent freeze your desktop enviroment while run xim program before
  19. #loading it in some case.
  20. #delay_time=0

  21. #im module setting for gtk & qt
  22. #set both of them to xim by default.
  23. gtk_im_module="xim"
  24. qt_im_module="xim"

  25. #use another locale instead of default settings
  26. #you should not use any LC_* enviroment variable here.
  27. #setxlocale='true' | 'false'
  28. #XLANGUAS="zh_CN.GB18030"
  29. #XLANG="zh_CN"
  30. #XLC_ALL=zh_CN.GB18030
  31. #XLC_CTYPE="zh_CN.GB18030"
  32. #XLC_NUMERIC="zh_CN.GB18030"
  33. #XLC_TIME="zh_CN.GB18030"
  34. #XLC_COLLATE="zh_CN.GB18030"
  35. #XLC_MONETARY="zh_CN.GB18030"
  36. #XLC_MESSAGES="zh_CN.GB18030"
  37. #XLC_PAPER="zh_CN.GB18030"
  38. #XLC_NAME="zh_CN.GB18030"
  39. #XLC_ADDRESS="zh_CN.GB18030"
  40. #XLC_TELEPHONE="zh_CN.GB18030"
  41. #XLC_MEASUREMENT="zh_CN.GB18030"
  42. #XLC_IDENTIFICATION="zh_CN.GB18030"
复制代码


好了,到这里就大功造成了。
发表于 2004-10-20 17:49:12 | 显示全部楼层
以前记得有人写过一个启动输入法的shell脚本,好象还更新版本呢。
呵呵。
发表于 2004-10-21 18:33:12 | 显示全部楼层
ln -s /usr/local/bin/xinputrc /etc/X11/xinit/xinitrc.d/100xinputrc
after i did this,i can not start X
so i remove this link
but now my fcitx does not work
when i start fcitx in a term
it will print
bash-2.05b# fcitx
没有设置XMODIFIERS!
now i can not input chinese
发表于 2004-11-17 18:01:58 | 显示全部楼层
你可以试用一下devilspie,它不但可以自动加载,还可以把加载的程序放到指定的工作区.我曾写过一篇文档,如果你有兴趣,我可以贴出来或者给我你的mail,我发给你.
发表于 2004-11-17 18:22:42 | 显示全部楼层
好复杂,用scim,只要在xinitrc里加三行就没问题了。
 楼主| 发表于 2004-11-17 18:40:12 | 显示全部楼层
已经改进到自动识别输入法了, 使用中文 portage, emerge glcxinput 即可。
发表于 2004-11-17 18:56:46 | 显示全部楼层
用gb18030有什么好处吗,似乎支持这个东西的字库不多啊
发表于 2004-11-17 20:55:48 | 显示全部楼层
好东西!不过我还是 startx + .xinitrc ……
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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