您尚未登录。

#1 2025-03-15 19:17:39

kls2012
会员
注册时间: 2025-03-15
帖子: 1

[分享配置] 根据 fcitx5 的状态更改sway当前窗口边框颜色

大家好(新人第一贴)。我今天在思考如何更科学的切换输入法,这里分享一下成果(需要 fcitx5-lua):

# ~/.local/share/fcitx5/addon/toggle_sway_border.conf
#
[Addon]
Name=Toggle Sway Border
Comment=Toggle sway border according to input method
Category=Module
Type=Lua
OnDemand=False
Configurable=False
Library=toggle_sway_border.lua

[Addon/Dependencies]
0=luaaddonloader
-- ~.local/share/fcitx5/lua/toggle_sway_border/toggle_sway_border.lua
-- 
local fcitx = require("fcitx")

fcitx.watchEvent(fcitx.EventType.SwitchInputMethod, "toggleSwayBorder")

local function onEnglish()
    os.execute [[swaymsg 'client.focused #285577 #285577 #ffffff #285577 #285577']]
end

local function onChinese()
    os.execute [[swaymsg 'client.focused #fbbc05 #fbbc05 #000000 #fbbc05 #fbbc05']]
end

function toggleSwayBorder(prev_im)
    if prev_im == "pinyin" then
        onEnglish()
    else
        onChinese()
    end
end

实现参考 https://www.aloxaf.com/2020/09/fcitx5_plugin/

我的想法是,现在显示器越来越大,我们越来越不容易瞥到系统托盘,记不住当前状态按错了总是很烦躁。那么干脆把输入法状态用最明显的方式表现出来:窗口颜色。这个信息你连想忽视掉都很难,就不容易按错了,顺便减少了对 system tray 的依赖。这时候'reset state on focus in' 和 'share input state' 这种辅助自动切换的功能反而是副作用了

没啥技术含量,抛砖引玉分享一下自己的想法。顺便问一下,fcitx5 可以关掉系统托盘吗?

最近编辑记录 kls2012 (2025-03-15 19:36:41)

离线

页脚