Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Create a keylock widget
- capslock = widget({ type = "textbox", align = "center" })
- capslock.width = 40
- scrolllock = widget({ type = "textbox", align = "center" })
- scrolllock.width = 44
- numlock = widget({ type = "textbox", align = "center" })
- numlock.width = 36
- do
- local update = function()
- local str = io.popen("xset q | grep Caps"):read()
- local caps = string.sub(str, string.find(str, "Caps"), string.find(str, "01") - 5):find("off") == nil
- local num = string.sub(str, string.find(str, "Num"), string.find(str, "02") - 5):find("off") == nil
- local scroll = string.sub(str, string.find(str, "Scroll"), -1):find("off") == nil
- local capsstr = "<span " .. (caps and "font_desc='Sans Bold'" or "color='" .. theme.fg_focus .. "'") .. ">Caps</span>"
- local numstr = "<span " .. (num and "font_desc='Sans Bold'" or "color='" .. theme.fg_focus .. "'") .. ">Num</span>"
- local scrollstr = "<span " .. (scroll and "font_desc='Sans Bold'" or "color='" .. theme.fg_focus .. "'") .. ">Scroll</span>"
- capslock.text = " " .. capsstr .. " "
- -- capslock.bg = caps and theme.bg_focus or theme.bg_normal
- scrolllock.text = " " .. scrollstr .. " "
- -- scrolllock.bg = scroll and theme.bg_focus or theme.bg_normal
- numlock.text = " " .. numstr .. " "
- -- numlock.bg = num and theme.bg_focus or theme.bg_normal
- end
- timer = timer { timeout = 0.001 }
- timer:add_signal( "timeout", function() update() end)
- timer:start()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement