Guest User

AwesomeWM kbdd layout widget

a guest
Apr 24th, 2012
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.82 KB | None | 0 0
  1. -- Keyboard layout widget
  2. function kbd ()
  3.     local lts = {[0] = "EN", [1] = "RU"}
  4.     local kbdwidget = widget({type = "textbox", name = "kbdwidget"})
  5.     local maketext = function (idx)
  6.         return "<span font_desc=\"Terminus Bold 10\" color=\"" .. beautiful.bg_normal .. "\">"..lts[idx].."</span>"
  7.     end
  8.  
  9.     kbdwidget.border_color = beautiful.fg_normal
  10.     kbdwidget.bg = beautiful.fg_normal
  11.     kbdwidget.width = 20
  12.     kbdwidget.align = "center"
  13.     kbdwidget.text = maketext(0)
  14.  
  15.     dbus.request_name("session", "ru.gentoo.kbdd")
  16.     dbus.add_match("session", "interface='ru.gentoo.kbdd',member='layoutChanged'")
  17.     dbus.add_signal("ru.gentoo.kbdd", function(...)
  18.         local data = {...}
  19.         local layout = data[2]
  20.         kbdwidget.text = maketext(layout)
  21.     end)
  22.  
  23.     return kbdwidget
  24. end
Advertisement
Add Comment
Please, Sign In to add comment