admin管理员组文章数量:1122832
I change my layouts with a very primitive xkb-switch
utility. I need to imitate the 'Share the same input method among all applications - disabled' behaviour of IBus.
My idea is such:
- When exiting a certain client I want to store the output of the
xkb-switch
shell command (it just lists my current layout:us(altgr-intl)
,am
orru
). - After some time, when entering back into that client, I want to switch the keyboard layout back (to the stored one) with the shell command
xkb-switch --switch <layout_here>
My attempt:
client.connect_signal("unfocus", function(c)
awful.spawn.easy_async_with_shell("xkb-switch", function(stdout)
if c.valid then
c.keyboard_layout = stdout
end
end)
end)
client.connect_signal("focus", function(c)
c = awful.screen.focused({client = true})
if c.keyboard_layout == nil then
c.keyboard_layout = "us(altgr-intl)"
end
awful.spawn.with_shell("xkb-switch -s "..c.keyboard_layout)
end)
Here is the behaviour: the notification popup is showing the intended language, but for some reason the switched language is wrong, is there some race hazard?
I change my layouts with a very primitive xkb-switch
utility. I need to imitate the 'Share the same input method among all applications - disabled' behaviour of IBus.
My idea is such:
- When exiting a certain client I want to store the output of the
xkb-switch
shell command (it just lists my current layout:us(altgr-intl)
,am
orru
). - After some time, when entering back into that client, I want to switch the keyboard layout back (to the stored one) with the shell command
xkb-switch --switch <layout_here>
My attempt:
client.connect_signal("unfocus", function(c)
awful.spawn.easy_async_with_shell("xkb-switch", function(stdout)
if c.valid then
c.keyboard_layout = stdout
end
end)
end)
client.connect_signal("focus", function(c)
c = awful.screen.focused({client = true})
if c.keyboard_layout == nil then
c.keyboard_layout = "us(altgr-intl)"
end
awful.spawn.with_shell("xkb-switch -s "..c.keyboard_layout)
end)
Here is the behaviour: the notification popup is showing the intended language, but for some reason the switched language is wrong, is there some race hazard? https://youtu.be/juarLneLBAo
Share Improve this question asked Nov 23, 2024 at 4:54 RobberFokZRobberFokZ 112 bronze badges1 Answer
Reset to default 0In the end I changed 2 lines of code and now this works:
client.connect_signal("unfocus", function(c)
awful.spawn.easy_async_with_shell("xkb-switch", function(stdout)
if c.valid then -- To avoid 'Invalid Object' error
c.keyboard_layout = stdout
end
end)
end)
client.connect_signal("focus", function(c)
if c.keyboard_layout == nil then
c.keyboard_layout = "us(altgr-intl)"
end
awful.spawn("xkb-switch -s "..c.keyboard_layout, false) -- `false` to prevent cursor being stuck in 'loading' state
end)
本文标签: luaUnique keyboard layout per clientStack Overflow
版权声明:本文标题:lua - Unique keyboard layout per client - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736299721a1930557.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论