Closed yanhuacuo closed 2 years ago
用 QDBus: 调用 org.fcitx.Fcitx5 上 /controller 对象的 org.fcitx.Fcitx.Controller1.SetConfig 方法
参数 fcitx://config/addon/rime/deploy ''
用 QDBus: 调用 org.fcitx.Fcitx5 上 /controller 对象的 org.fcitx.Fcitx.Controller1.SetConfig 方法
参数 fcitx://config/addon/rime/deploy ''
感谢回复,
下面的指令,让 fcitx5-rime 重新部署是有效的:
qdbus org.fcitx.Fcitx5 /controller org.fcitx.Fcitx.Controller1.SetConfig "fcitx://config/addon/rime/deploy" ""
注意到 fcitx5/blob/master/src/modules/dbus/dbusmodule.cpp 中有定义一些公有成员,比如 exit()
或 restart()
,但是尝试仿写无效。
qdbus org.fcitx.Fcitx5 /controller org.fcitx.Fcitx.Controller1.SetConfig "fcitx://config/addon/rime/exit" ""
或
qdbus org.fcitx.Fcitx5 /controller org.fcitx.Fcitx.Controller1.SetConfig "fcitx://config/addon/rime" "exit"`
或
qdbus org.fcitx.Fcitx5 /controller org.fcitx.Fcitx.Controller1.SetConfig "fcitx://config/addon/rime" "exit()"
又或
qdbus org.fcitx.Fcitx5 /controller org.fcitx.Fcitx.Controller1.SetConfig "fcitx://config/addon/rime/exit()" ""
都不能让 fcitx5-rime 的 librime 引擎退出。
求指点正确的用法
目前使用较为丑陋的 bash 管道命令
void MainWindow::on_btnFcitxOFF_clicked()
{
QProcess process;
process.startDetached("/bin/bash", {"-c" , "kill `ps -A | grep fcitx5 | awk '{print $1}'`"});
}
void MainWindow::on_btnFcitxON_clicked()
{
QProcess process;
QString b = QString("\"%1\" ").arg("fcitx://config/addon/rime/deploy");
QString a = "qdbus org.fcitx.Fcitx5 /controller org.fcitx.Fcitx.Controller1.SetConfig ";
QString c = "\"\"";
QString d = a+b+c;
process.startDetached("/bin/bash", {"-c" , "fcitx5 -d"});
process.startDetached("/bin/bash", {"-c" , d});
}
@yanhuacuo 为什么要退出,我给你的方法和squirrel —reload是等价的
@yanhuacuo 为什么要退出,我给你的方法和squirrel —reload是等价的,但我期望有与
Squirrel --exit
等价的实现。
因为只有 librime 的进程退出后,它才会真正释放上屏记录文件( xxx.txt )。仅仅是 reload
的话,每一次都只是在本地生成一份 xxx.txt 。这而份 xxx.txt 里的条目,是能被打出来的。
譬如有一条词条 风花雪月
,一旦用户「打过」该词,它就会被收入到上屏记录中,当用户想删掉它时,无论是在 dict.yaml 中删,还是去 build 中清空 bin,都不能实现目的,因为 reload 时,它会重新生成一份 xxx.txt。
所以解决办法就是让 librime 的进程暂时退出,清掉 build 中的 bin 文件,这时对 xxx.txt 的操控,会成为 librime 再次启动时加载上屏记录的唯一依据。
weasel 和 squirrel ,都有 exit 指令,可以暂退 librime,在 fcitx 上,我只实现了用 shell 这种比较有入侵性的方式达成上述目的。
已经解决了这个问题,不需要杀进程了。 :)
请问是怎么解决的?
@nkta3m 看到您在好几个 issue 里问类似的问题。
我感觉 OP 的方法应该是 qdbus org.fcitx.Fcitx5 /controller org.fcitx.Fcitx.Controller1.SetConfig fcitx://config/addon/rime/sync ''
所以解决办法就是让 librime 的进程暂时退出,清掉 build 中的 bin 文件,这时对 xxx.txt 的操控,会成为 librime 再次启动时加载上屏记录的唯一依据。
find ~/.local/share/fcitx5/rime -name "rime_ice*.userdb*" | xargs -I{} rm -rf {}
然后 sync
,之前的 rime_ice
记录会都清空。
不过注意,Fcitx5 应该是不会特定处理诸如 LOCK 的问题 hchunhui/librime-lua#330,需要用户自己避免 LOCK 问题。所以这个 comment 我一开始想问yanhuacuo怎么处理他的问题的
P.s. kde6 里如果一定要重启 Fcitx5 的话(一般情况不需要,上述 sync 基本可以重新导入 rime yaml 配置),关掉 Fcitx5 后,暂时可以在 systemsettings kcm_virtualkeyboard
里面先 apply 'Fcitx 5 Wayland Launcher',然后再 apply 'Fcitx 5',可以用 (y)dotool 自动化。
我们在开发一款可视化的 rime 助手 : 中州韵98五笔助手
现在有一个需求是这样的,我们期望在 rime 助手可视化管理词库时, librime 的算法服务可以使用
QProcess
(Qt类库) 控制退出或唤醒,因为 librime 在运行时,它实际上在占用着「上屏历史文件」,只有算服务服退出了,它才会真正解除对这个文件的占用。我查到
fcitx5
有一些内置命令,如下,似乎fcitx5 --disable rime
应该是可用的,但实际上它并不能结束掉 fcitx5-rime 的相关进程。--replace
会重新加载,-s + seconds
的功能没看明白,没有找到合适的方法。 大佬,fcitx5-rime 是否有Squirrel --reload
或Squirrel --exit
类似的 API ?