]> git.madduck.net Git - etc/awesome.git/blobdiff - widgets/mem.lua

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

readme updated
[etc/awesome.git] / widgets / mem.lua
index d0ff223966549c845dd48d9440ee3a2db3d1ffe0..f0141494247700b4c3ee6ec8295a129fc2b3f743 100644 (file)
@@ -25,14 +25,14 @@ local setmetatable    = setmetatable
 -- lain.widgets.mem
 local mem = {}
 
-function worker(args)
+local function worker(args)
     local args     = args or {}
     local timeout  = args.timeout or 3
     local settings = args.settings or function() end
 
-    widget = wibox.widget.textbox('')
+    mem.widget = wibox.widget.textbox('')
 
-    function update()
+    function mem.update()
         mem = {}
         for line in io.lines("/proc/meminfo")
         do
@@ -51,12 +51,13 @@ function worker(args)
         used = mem.total - (mem.free + mem.buf + mem.cache)
         swapused = mem.swap - mem.swapf
 
+        widget = mem.widget
         settings()
     end
 
-    newtimer("mem", timeout, update)
+    newtimer("mem", timeout, mem.update)
 
-    return widget
+    return mem.widget
 end
 
 return setmetatable(mem, { __call = function(_, ...) return worker(...) end })