Skip to content

Instantly share code, notes, and snippets.

@riccardosven
Last active December 13, 2015 10:14
Show Gist options
  • Save riccardosven/a357daf787168cb1fbd2 to your computer and use it in GitHub Desktop.
Save riccardosven/a357daf787168cb1fbd2 to your computer and use it in GitHub Desktop.
Lua function to change keyboard layout.
function ()
-- Rotate keyboards table,
-- requires a global variable called keyboards with the layouts listed,
-- e.g. keyboards = {'dvorak','us','us dvorak-intl'}
table.insert(keyboards,table.remove(keyboards,1))
-- Extract first layout
local new_layout = keyboards[1]
-- Set keymap to chosen layout
awful.util.spawn("setxkbmap "..new_layout)
-- Optional notification of new layout
naughty.notify({preset = naughty.config.presets.normal,
font = "monospace 10",
screen = mouse.screen,
text = "KB: "..new_layout,
timeout = 1})
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment