LinuxSir.cn,穿越时空的Linuxsir!

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

以su出的root身份运行的GTK+程序无法使用fcitx?

[复制链接]
发表于 2011-9-16 11:28:19 | 显示全部楼层 |阅读模式

  • 环境:app-i18n/fcitx-4.1.1::gentoo-zh,LANG=en_US.UTF-8
  • fcitx以用户richard身份运行。以用户richard身份运行的GTK+程序可使用fcitx。
  • 以su -l的root身份运行GTK+程序,没有DBUS_SESSION_BUS_ADDRESS,设置GTK_IM_MODULE=fcitx,无法使用fcitx;
  • 以su的root身份运行GTK+程序,有DBUS_SESSION_BUS_ADDRESS,设置GTK_IM_MODULE=fcitx,无法使用fcitx,且有如下warning:
    1. ** (gvim:5396): WARNING **: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
    复制代码
  • 以su -l的root身份运行GTK+程序,设置GTK_IM_MODULE=fcitx,无法使用fcitx。
  • 以su/su -l的root身份运行GTK+程序,设置GTK_IM_MODULE=xim,可以使用fcitx;
  • 以su -l的root身份运行"dbus-launch --exit-with-session GTK+程序",无法使用fcitx。

呃,问题究竟在哪里...

.xinitrc:
  1. # == xinitrc.d ==
  2. if [ -d /etc/X11/xinit/xinitrc.d ] ; then
  3.         for f in /etc/X11/xinit/xinitrc.d/* ; do
  4.                 [ -x "$f" ] && . "$f"
  5.         done
  6.         unset f
  7. fi
  8. # == ibus ==
  9. # export XMODIFIERS="@im=ibus"
  10. # export GTK_IM_MODULE="ibus"
  11. # export QT_IM_MODULE="xim"
  12. # ibus-daemon -d -x
  13. # == fcitx ==
  14. export XMODIFIERS="@im=fcitx"
  15. export XIM=fcitx
  16. export XIM_PROGRAM=fcitx
  17. export QT_IM_MODULE=fcitx
  18. export GTK_IM_MODULE=fcitx
  19. # fcitx &
  20. # == env ==
  21. export GTK2_RC_FILES="$HOME/.gtkrc-2.0"
  22. export _JAVA_OPTIONS='-Dawt.useSystemAAFontSettings=on'
  23. # == misc ==
  24. xrdb -merge ~/.Xresources
  25. # feh --bg-center wallpapers/gentoo-minimal-1600x1200.jpg
  26. feh --bg-center wallpapers/grass.jpg
  27. # exec dbus-launch --exit-with-session --sh-syntax ck-launch-session fvwm
  28. exec fvwm
复制代码
发表于 2011-9-16 11:46:07 | 显示全部楼层
用im module的话dbus的session是应该是不能跨用户的。在同一个X下面xim总是可以工作,不管是哪个用户。

——csslayer的原话
回复 支持 反对

使用道具 举报

 楼主| 发表于 2011-9-16 12:18:12 | 显示全部楼层
Post by Mishell;2152155
用im module的话dbus的session是应该是不能跨用户的。在同一个X下面xim总是可以工作,不管是哪个用户。

——csslayer的原话


哦,谢谢。看来白折腾了两个小时dbus...

另外,我原本打算看看这句话前后的内容,不过万能的Google居然没找到... 能否给一个原文的链接?
回复 支持 反对

使用道具 举报

发表于 2011-9-16 12:25:10 | 显示全部楼层
Post by RichardGv;2152161
哦,谢谢。看来白折腾了两个小时dbus...

另外,我原本打算看看这句话前后的内容,不过万能的Google居然没找到... 能否给一个原文的链接?


https://groups.google.com/forum/#!topic/fcitx-dev/pyk2zIdCrGg
回复 支持 反对

使用道具 举报

 楼主| 发表于 2011-9-16 13:38:22 | 显示全部楼层

哦,多谢。

目前只好把这些加入/etc/zsh/zshrc来解决了。
  1. # == fcitx ==
  2. export XMODIFIERS="@im=fcitx"
  3. export XIM=fcitx
  4. export XIM_PROGRAM=fcitx
  5. export QT_IM_MODULE=fcitx
  6. if [ $((ps -ouid= -C fcitx || ps -ouid= -C xinit || echo 1000) \
  7.                 | tr -d ' ') = $(id -u) ]; then
  8.         export GTK_IM_MODULE=fcitx
  9. else
  10.         export GTK_IM_MODULE=xim
  11. fi
复制代码
回复 支持 反对

使用道具 举报

发表于 2011-9-17 09:14:34 | 显示全部楼层
几乎没怎么用过su,一般sudo就解决问题了。
用sudo来启动某个gtk程序是没有这个问题的。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2011-9-17 11:38:38 | 显示全部楼层
Post by zhou3345;2152230
几乎没怎么用过su,一般sudo就解决问题了。
用sudo来启动某个gtk程序是没有这个问题的。

我这里sudo是不成的... gksu/gksudo亦然。嗯,看来是平时扶老太太过马路太少了...

由于su比sudo少两个字母,个人一直偏好su。
回复 支持 反对

使用道具 举报

发表于 2011-9-17 12:29:25 | 显示全部楼层
我原来一直用的都是xim,也没去理解dbus是怎么个工作方式,直到那天升级之后有问题了才关注了一下,不知道我的经历是否能给楼主帮助,反正留在这里吧:http://code.google.com/p/fcitx/issues/detail?id=419
回复 支持 反对

使用道具 举报

 楼主| 发表于 2011-9-17 21:01:06 | 显示全部楼层
Post by zhou3345;2152247
我原来一直用的都是xim,也没去理解dbus是怎么个工作方式,直到那天升级之后有问题了才关注了一下,不知道我的经历是否能给楼主帮助,反正留在这里吧:http://code.google.com/p/fcitx/issues/detail?id=419

嗯,多谢了。

我也是在fcitx 4.1发布之后才开始研究dbus的,之前一直依赖autolaunch的dbus,经常出现一堆dbus-launch --auto-launch进程...
csslayer对我等wm用户的狂轰滥炸也功不可没 ( https://www.csslayer.tk/wordpres ... wm-as-your-desktop/ )

由于我的.xinitrc执行了/etc/X11/xinit/xinitrc.d/80-dbus和/etc/X11/xinit/xinitrc.d/90-consolekit(Gentoo dev为何不像Arch一样留一个/etc/skel/.xinitrc,害我走了无数弯路...),dbus-launch和ck-launch-session均已在fvwm执行执行之前运行,故dbus和consolekit之启动应非此问题之根源。以一般用户身份使用fcitx的GTK+ immodule正常,也验证了这一点。On the spot的光标跟随亦未见异常。

目前怀疑问题出在dbus的跨用户通信上,可参考man dbus-launch:
  1.        The  second common reason for autolaunch is an su to another user, and display of X applications run‐
  2.        ning as the second user on the display belonging to the first user. Perhaps the  ideal  fix  in  this
  3.        case  would be to allow the second user to connect to the session bus of the first user, just as they
  4.        can connect to the first user's display.  However, a mechanism for that has not been coded.
复制代码
呜, mechanism for that has not been coded... 此问题的解决看来尚需时日。
回复 支持 反对

使用道具 举报

发表于 2011-9-17 22:18:54 | 显示全部楼层
Post by RichardGv;2152284

csslayer对我等wm用户的狂轰滥炸也功不可没 ( https://www.csslayer.tk/wordpres ... wm-as-your-desktop/ )

是啊,我是那篇文章的正主,上面给的链接便是由头。


不过我这里用sudo的话,gtk程序可以正常使用fcitx,但su下面不行。
回复 支持 反对

使用道具 举报

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

本版积分规则

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