您尚未登录。

#1 2024-07-16 09:42:21

Tee
会员
注册时间: 2016-09-10
帖子: 141
个人网站

[已解决]如何在 zenity 对话框弹出之后自动激活 fcitx?

请教如何在 zenity 对话框弹出之后自动激活 fcitx?
我的想法是 zenity entry 弹窗一出来就运行 fcitx-remote -o,但不知道该如何实现

最近编辑记录 Tee (2024-07-16 10:12:43)


啦哆咪 - 用Linux制作音乐
https://lado.me

离线

#2 2024-07-16 10:05:09

依云
会员
所在地: a.k.a. 百合仙子
注册时间: 2011-08-21
帖子: 8,773
个人网站

Re: [已解决]如何在 zenity 对话框弹出之后自动激活 fcitx?

你可以让 fcitx5 对 zenity 默认激活。在 ~/.local/share/fcitx5/lua/imeapi/extensions 创建一个 .lua 文件,写上:

local fcitx = require("fcitx")

local app_im = {
  ['zenity'] = '你想要用的输入法',
}

function onContextCreated()
  local p = fcitx.currentProgram()
  local colon = p:find(':', 1, true)
  if colon then
    p = p:sub(1, colon-1)
  end

  local a = app_im[p]
  if a then
    fcitx.setCurrentInputMethod(a, true)
  end
end

fcitx.watchEvent(fcitx.EventType.ContextCreated, "onContextCreated")

脚本修改自 https://github.com/hosxy/fcitx5-lua-spusim

离线

#3 2024-07-16 10:12:23

Tee
会员
注册时间: 2016-09-10
帖子: 141
个人网站

Re: [已解决]如何在 zenity 对话框弹出之后自动激活 fcitx?

酷!感谢


啦哆咪 - 用Linux制作音乐
https://lado.me

离线

页脚