aboutsummaryrefslogtreecommitdiff
path: root/mem.lua
diff options
context:
space:
mode:
authorAdrian C. (anrxc) <anrxc@sysphere.org>2010-03-14 01:55:33 +0100
committerAdrian C. (anrxc) <anrxc@sysphere.org>2010-03-14 01:55:33 +0100
commit237470c8f45190b213e3a173ce6ae1a74b3e11fe (patch)
tree7f53c8144761947d4bde20715bcad34f4be0d6c0 /mem.lua
parent9a82d4113a8271b7dfc7506f2b07379e3ede89a8 (diff)
downloadvicious-legacy-237470c8f45190b213e3a173ce6ae1a74b3e11fe.tar.xz
API: transform widgets namespace table to a directory
Diffstat (limited to 'mem.lua')
-rw-r--r--mem.lua49
1 files changed, 0 insertions, 49 deletions
diff --git a/mem.lua b/mem.lua
deleted file mode 100644
index 7c18c89..0000000
--- a/mem.lua
+++ /dev/null
@@ -1,49 +0,0 @@
----------------------------------------------------
--- Licensed under the GNU General Public License v2
--- * (c) 2010, Adrian C. <anrxc@sysphere.org>
--- * (c) 2009, Lucas de Vries <lucas@glacicle.com>
----------------------------------------------------
-
--- {{{ Grab environment
-local io = { lines = io.lines }
-local setmetatable = setmetatable
-local math = { floor = math.floor }
-local string = { gmatch = string.gmatch }
--- }}}
-
-
--- Mem: provides RAM and Swap usage statistics
-module("vicious.mem")
-
-
--- {{{ Memory widget type
-local function worker(format)
- local mem = { buf = {}, swp = {} }
-
- -- Get MEM info
- 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.buf.f = math.floor(v/1024)
- elseif k == "Buffers" then mem.buf.b = math.floor(v/1024)
- elseif k == "Cached" then mem.buf.c = math.floor(v/1024)
- elseif k == "SwapTotal" then mem.swp.t = math.floor(v/1024)
- elseif k == "SwapFree" then mem.swp.f = math.floor(v/1024)
- end
- end
- end
-
- -- Calculate memory percentage
- mem.free = mem.buf.f + mem.buf.b + mem.buf.c
- mem.inuse = mem.total - mem.free
- mem.usep = math.floor(mem.inuse / mem.total * 100)
- -- Calculate swap percentage
- mem.swp.inuse = mem.swp.t - mem.swp.f
- mem.swp.usep = math.floor(mem.swp.inuse / mem.swp.t * 100)
-
- return {mem.usep, mem.inuse, mem.total, mem.free,
- mem.swp.usep, mem.swp.inuse, mem.swp.t, mem.swp.f}
-end
--- }}}
-
-setmetatable(_M, { __call = function(_, ...) return worker(...) end })