79217415

Date: 2024-11-23 08:17:36
Score: 0.5
Natty:
Report link

In 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)
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: RobberFokZ