vincentbernat.i3wm-configur.../rc/keyboard.lua
Vincent Bernat f5aa2a1b51 keyboard: simplify configuration
xmodmap seems to modify the layout and will be kept if we switch to
another layout. Therefore, we only need to call it on start. Just move
the keyboard configuration to `start.lua`. `keyboard.lua` is just here
to manage kbdd.
2012-07-16 17:59:23 +02:00

38 lines
1.2 KiB
Lua

-- Keyboard configuration with kbdd
local icons = loadrc("icons", "vbe/icons")
local qdbus = {
check = "qdbus ru.gentoo.KbddService /ru/gentoo/KbddService",
next = "qdbus ru.gentoo.KbddService /ru/gentoo/KbddService ru.gentoo.kbdd.next_layout"
}
-- Display a notification if the layout changed
local nid = nil
dbus.request_name("session", "ru.gentoo.kbdd")
dbus.add_match("session", "interface='ru.gentoo.kbdd',member='layoutNameChanged'")
dbus.add_signal("ru.gentoo.kbdd",
function(...)
local data = {...}
local layout = data[2]
local screen = mouse.screen
if client.focus then screen = client.focus.screen end
nid = naughty.notify({ title = "Keyboard layout changed",
text = "New layout is <i>" .. layout .. "</i>",
replaces_id = nid,
icon = icons.lookup({ name = "keyboard",
type = "devices" }),
screen = screen }).id
end)
config.keys.global = awful.util.table.join(
config.keys.global,
awful.key({ modkey }, "=",
function()
os.execute(qdbus.next)
end, "Change keyboard layout"))
-- Run kbdd if not running
if os.execute(qdbus.check .. " 2> /dev/null > /dev/null") ~= 0 then
awful.util.spawn("kbdd")
end