-local mem = {}
-
-function worker(args)
- local args = args or {}
- local refresh_timeout = args.refresh_timeout or 10
- local show_swap = args.show_swap or false
- local show_total = args.show_total or false
- local header = args.header or " Mem "
- local header_color = args.header or beautiful.fg_normal or "#FFFFFF"
- local color = args.color or beautiful.fg_focus or "#FFFFFF"
- local footer = args.footer or "MB "
-
- local widg = wibox.widget.textbox()
-
- local upd = function()
- local mem = {}
- for line in io.lines("/proc/meminfo")
- do
- for k, v in string.gmatch(line, "([%a]+):[%s]+([%d]+).+")
- do
- if k == "MemTotal" then mem.total = math.floor(v / 1024)
- elseif k == "MemFree" then mem.free = math.floor(v / 1024)
- elseif k == "Buffers" then mem.buf = math.floor(v / 1024)
- elseif k == "Cached" then mem.cache = math.floor(v / 1024)
- elseif k == "SwapTotal" then mem.swap = math.floor(v / 1024)
- elseif k == "SwapFree" then mem.swapf = math.floor(v / 1024)
+local mem = helpers.make_widget_textbox()
+
+local function worker(args)
+ local args = args or {}
+ local timeout = args.timeout or 2
+ local settings = args.settings or function() end
+
+ function update()
+ mem_now = {}
+ for line in lines("/proc/meminfo") do
+ for k, v in gmatch(line, "([%a]+):[%s]+([%d]+).+") do
+ if k == "MemTotal" then mem_now.total = floor(v / 1024 + 0.5)
+ elseif k == "MemFree" then mem_now.free = floor(v / 1024 + 0.5)
+ elseif k == "Buffers" then mem_now.buf = floor(v / 1024 + 0.5)
+ elseif k == "Cached" then mem_now.cache = floor(v / 1024 + 0.5)
+ elseif k == "SwapTotal" then mem_now.swap = floor(v / 1024 + 0.5)
+ elseif k == "SwapFree" then mem_now.swapf = floor(v / 1024 + 0.5)
+ elseif k == "SReclaimable" then mem_now.srec = floor(v / 1024 + 0.5)