diff --git a/rc.lua b/rc.lua index ab1e77d..711ea2f 100644 --- a/rc.lua +++ b/rc.lua @@ -54,8 +54,10 @@ config.hostname = awful.util.pread('uname -n'):gsub('\n', '') -- Remaining modules loadrc("xrun") -- xrun function loadrc("appearance") -- theme and appearance settings + 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 diff --git a/rc/keyboard.lua b/rc/keyboard.lua new file mode 100644 index 0000000..2739e52 --- /dev/null +++ b/rc/keyboard.lua @@ -0,0 +1,55 @@ +-- Keyboard configuration with kbdd + +-- 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 + +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 " .. layout .. "", + replaces_id = nid, + icon = "/usr/share/icons/gnome/32x32/devices/keyboard.png", + screen = client.focus.screen }).id + end) + +config.keys.global = awful.util.table.join( + config.keys.global, + awful.key({ modkey }, "=", + function() + os.execute(qdbus.next) + end)) + +-- Run kbdd if not running +if os.execute(qdbus.check .. " 2> /dev/null > /dev/null") ~= 0 then + awful.util.spawn("kbdd") +end diff --git a/rc/start.lua b/rc/start.lua index 6a88935..12d714b 100644 --- a/rc/start.lua +++ b/rc/start.lua @@ -24,23 +24,17 @@ local execute = { if config.hostname == "naruto" then execute = awful.util.table.join( execute, { - -- Keyboard configuration "xset m 4 3", -- Mouse acceleration - "setxkbmap us '' compose:rwin ctrl:nocaps", - "xmodmap -e 'keysym Pause = XF86ScreenSaver'" }) + }) elseif config.hostname == "neo" then execute = awful.util.table.join( execute, { -- Keyboard configuration "xset m 3 3", -- Mouse acceleration - "setxkbmap us '' compose:rwin ctrl:nocaps", - "xmodmap -e 'keysym Pause = XF86ScreenSaver'"}) + }) elseif config.hostname == "guybrush" then execute = awful.util.table.join( execute, { - -- Keyboard configuration - "setxkbmap us '' compose:rctrl ctrl:nocaps", - "xmodmap -e 'keysym XF86AudioPlay = XF86ScreenSaver'", -- Wheel emulation "xinput set-int-prop 'TPPS/2 IBM TrackPoint' 'Evdev Wheel Emulation' 8 1", "xinput set-int-prop 'TPPS/2 IBM TrackPoint' 'Evdev Wheel Emulation Button' 8 2",