2012-07-14 12:29:48 +02:00
|
|
|
-- Keyboard configuration with kbdd
|
|
|
|
|
2012-07-15 22:22:38 +02:00
|
|
|
local icons = loadrc("icons", "vbe/icons")
|
|
|
|
|
2012-07-14 12:29:48 +02:00
|
|
|
-- Global configuration
|
|
|
|
if config.hostname == "guybrush" then
|
|
|
|
os.execute("setxkbmap us,fr '' compose:rctrl ctrl:nocaps")
|
|
|
|
else
|
|
|
|
os.execute("setxkbmap us,fr '' compose:rwin ctrl:nocaps")
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Additional mappings
|
|
|
|
local mappings = { Pause = "XF86ScreenSaver" }
|
|
|
|
if config.hostname == "guybrush" then
|
|
|
|
mappings = { XF86AudioPlay = "XF86ScreenSaver" }
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local function update_mappings()
|
|
|
|
for src, dst in pairs(mappings) do
|
|
|
|
os.execute(string.format("xmodmap -e 'keysym %s = %s'", src, dst))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-07-16 17:30:16 +02:00
|
|
|
update_mappings()
|
|
|
|
|
2012-07-14 12:29:48 +02:00
|
|
|
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]
|
|
|
|
update_mappings()
|
|
|
|
nid = naughty.notify({ title = "Keyboard layout changed",
|
|
|
|
text = "New layout is <i>" .. layout .. "</i>",
|
|
|
|
replaces_id = nid,
|
2012-07-15 22:22:38 +02:00
|
|
|
icon = icons.lookup({ name = "keyboard",
|
|
|
|
type = "devices" }),
|
2012-07-14 12:29:48 +02:00
|
|
|
screen = client.focus.screen }).id
|
|
|
|
end)
|
|
|
|
|
|
|
|
config.keys.global = awful.util.table.join(
|
|
|
|
config.keys.global,
|
|
|
|
awful.key({ modkey }, "=",
|
|
|
|
function()
|
|
|
|
os.execute(qdbus.next)
|
2012-07-15 01:02:30 +02:00
|
|
|
end, "Change keyboard layout"))
|
2012-07-14 12:29:48 +02:00
|
|
|
|
|
|
|
-- Run kbdd if not running
|
|
|
|
if os.execute(qdbus.check .. " 2> /dev/null > /dev/null") ~= 0 then
|
|
|
|
awful.util.spawn("kbdd")
|
|
|
|
end
|