Reputation: 21
I want to use dbus to update my keyboard layout indicator in awesome wm. Here is my func in lua
module("keyb")
function getklayout()
local fd = io.popen("skb a")
local layout = fd:read()
fd:close()
return layout
end
and part of rc.lua
require("keyb")
keyinc = widget({type = "textbox"})
keyinc.text = keyb.getklayout()
I'm not sure what dbus service i need to use to update this widget. My awesome version:
awesome -v
awesome v3.4.9 (Smack)
• Build: Apr 9 2011 10:40:59 for i686 by gcc version 4.5.1 ([email protected])
• D-Bus support: ✔
need an advise )
Upvotes: 2
Views: 2150
Reputation: 11
I was using skb before. And using timer for periodically checking keyboard state. But this is not good. Now I am using dbus and kbdd for this. First starting kbdd. And add in rc.lua:
--- {{{ keyboard indicator
mykeyindicator = widget({ type = "imagebox", align = "right" })
mykeyindicator.image = image(home_dir .. "/.icons/flags/Eng.png")
function mykey_update(...)
local data = {...}
local layout = data[2]
lts = {
[0] = home_dir .. "/.icons/flags/Eng.png",
[1] = home_dir .. "/.icons/flags/Rus.png",
}
mykeyindicator.image = image(lts[layout])
return
end
dbus.request_name("session", "ru.gentoo.kbdd")
dbus.add_match("session", "interface='ru.gentoo.kbdd',member='layoutChanged'")
dbus.add_signal("ru.gentoo.kbdd", mykey_update)
--- keyboard indicator }}}
Kbdd home page: https://github.com/qnikst/kbdd
Upvotes: 1