keyboard: use XKB groups to switch between layouts

The use of XKB groups allow to switch between layouts with a key
combination (RCTRL + RSHIFT in our case). I don't need kbdd since I am
not really interested in switching keyboard layout per window.
This commit is contained in:
Vincent Bernat 2012-07-20 15:14:29 +02:00
parent dad27fe5d0
commit 63eb3ff794
3 changed files with 4 additions and 42 deletions

1
rc.lua
View file

@ -67,7 +67,6 @@ loadrc("debug") -- debugging primitive `dbg()`
loadrc("start") -- programs to run on start
loadrc("bindings") -- keybindings
loadrc("keyboard") -- keyboard configuration
loadrc("wallpaper") -- wallpaper settings
loadrc("tags") -- tags handling
loadrc("widgets") -- widgets configuration

View file

@ -1,38 +0,0 @@
-- 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

View file

@ -23,12 +23,13 @@ local execute = {
"xrdb -merge " .. awful.util.getdir("config") .. "/Xresources",
}
-- Keyboard/Mouse configuration
if config.hostname == "naruto" then
execute = awful.util.table.join(
execute, {
-- Keyboard and mouse
"xset m 4 3", -- Mouse acceleration
"setxkbmap us,fr '' compose:rwin ctrl:nocaps",
"setxkbmap us,fr '' compose:rwin ctrl:nocaps grp:rctrl_rshift_toggle",
"xmodmap -e 'keysym Pause = XF86ScreenSaver'",
})
elseif config.hostname == "neo" then
@ -36,14 +37,14 @@ elseif config.hostname == "neo" then
execute, {
-- Keyboard and mouse
"xset m 3 3", -- Mouse acceleration
"setxkbmap us,fr '' compose:rwin ctrl:nocaps",
"setxkbmap us,fr '' compose:rwin ctrl:nocaps grp:rctrl_rshift_toggle",
"xmodmap -e 'keysym Pause = XF86ScreenSaver'",
})
elseif config.hostname == "guybrush" then
execute = awful.util.table.join(
execute, {
-- Keyboard and mouse
"setxkbmap us,fr '' compose:rctrl ctrl:nocaps",
"setxkbmap us,fr '' compose:ralt ctrl:nocaps grp:rctrl_rshift_toggle",
"xmodmap -e 'keysym XF86AudioPlay = XF86ScreenSaver'",
-- Wheel emulation
"xinput set-int-prop 'TPPS/2 IBM TrackPoint' 'Evdev Wheel Emulation' 8 1",