X-Git-Url: https://git.madduck.net/etc/awesome.git/blobdiff_plain/f37a31878edfb59d56c2b0fde04ae80c46a8809e..5383f3db0dbb7e06f09a61e1db803a656abe252e:/widgets/base.lua?ds=inline diff --git a/widgets/base.lua b/widgets/base.lua index 39b0863..94ee58f 100644 --- a/widgets/base.lua +++ b/widgets/base.lua @@ -7,9 +7,8 @@ --]] local newtimer = require("lain.helpers").newtimer +local read_pipe = require("lain.helpers").read_pipe local wibox = require("wibox") - -local io = { popen = io.popen } local setmetatable = setmetatable -- Basic template for custom widgets @@ -22,14 +21,15 @@ local function worker(args) local cmd = args.cmd or "" local settings = args.settings or function() end - base.widget = wibox.widget.textbox('') + base.widget = wibox.widget.textbox() function base.update() - local f = assert(io.popen(cmd)) - output = f:read("*a") - f:close() - widget = base.widget - settings() + output = read_pipe(cmd) + if output ~= base.prev then + widget = base.widget + settings() + base.prev = output + end end newtimer(cmd, timeout, base.update)