Skip to content

Instantly share code, notes, and snippets.

@starenka
Created August 19, 2012 08:00
Show Gist options
  • Save starenka/3393511 to your computer and use it in GitHub Desktop.
Save starenka/3393511 to your computer and use it in GitHub Desktop.
-- Keyboard layout switching
kbdcfg = {
cmd = "setxkbmap",
layout = { "us", "cz -variant qwerty" },
current = 1,
widget = widget({ type = "textbox", align = "right" })
}
kbdcfg.switch = function()
kbdcfg.current = kbdcfg.current % #(kbdcfg.layout) + 1
local t = " " .. kbdcfg.layout[kbdcfg.current] .. " "
kbdcfg.widget.text = t:gsub('%s%-variant%s', ':')
os.execute(kbdcfg.cmd .. t)
end
kbdcfg.widget.text = " " .. kbdcfg.layout[kbdcfg.current] .. " "
-- Mouse bindings
kbdcfg.widget:buttons(awful.util.table.join(awful.button({}, 1, function() kbdcfg.switch() end)))
-- {{{ Key bindings (use xev)
globalkeys = awful.util.table.join(
...
awful.key({ ctrlkey, altkey }, "k", function() kbdcfg.switch() end),
...
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment