I'm trying to create my first widget for awesome. I've often have troubles
remembering what's in what X11 buffer (PRIMARY, SECONDARY, and CLIPBOARD). Thus
I wrote a little widget that shows me the contents. However, this widget seems
to cause awesome to freeze after a couple of hours of use.
I instantiate it this way:
-- selection box
cselp = widget({ type = "textbox"})
vicious.register(cselp, clip, '<span color="yellow">Pri: </span> $1 ||', 1,
"primary")
Any ideas?
Thanks.
-- {{{ Grab environment
local io = { popen = io.popen }
local math = { max = math.max }
local setmetatable = setmetatable
-- }}}
-- Pkg: provides number of pending updates on UNIX systems
module("clip")
-- {{{ Packages widget type
local function worker(format, warg)
if not warg then return end
-- Initialize counters
local updates = 0
local manager = {
["clipboard"] = { cmd = "xsel -b" },
["primary"] = { cmd = "xsel -p" },
["secondary"] = { cmd = "xsel -s" },
}
-- get the output
local pkg = manager[warg]
local f = io.popen(pkg.cmd)
local line = f:read()
f:close()
if line == nil then
line = ""
end
return { line:gsub('<','<') }
end
-- }}}
setmetatable(_M, { __call = function(_, ...) return worker(...) end })
--
NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone!
Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a
--
To unsubscribe, send mail to [email protected].