Skip to content

Commit 979cc46

Browse files
authored
Merge pull request #59 from jgkamat/jay/memavailable
Use MemAvailable for mem.free
2 parents a081bf7 + 0db5f3f commit 979cc46

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

widgets/mem_linux.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ local function worker(format)
2626
for k, v in string.gmatch(line, "([%a]+):[%s]+([%d]+).+") do
2727
if k == "MemTotal" then _mem.total = math.floor(v/1024)
2828
elseif k == "MemFree" then _mem.buf.f = math.floor(v/1024)
29+
elseif k == "MemAvailable" then _mem.buf.a = math.floor(v/1024)
2930
elseif k == "Buffers" then _mem.buf.b = math.floor(v/1024)
3031
elseif k == "Cached" then _mem.buf.c = math.floor(v/1024)
3132
elseif k == "SwapTotal" then _mem.swp.t = math.floor(v/1024)
@@ -35,7 +36,7 @@ local function worker(format)
3536
end
3637

3738
-- Calculate memory percentage
38-
_mem.free = _mem.buf.f + _mem.buf.b + _mem.buf.c
39+
_mem.free = _mem.buf.a
3940
_mem.inuse = _mem.total - _mem.free
4041
_mem.bcuse = _mem.total - _mem.buf.f
4142
_mem.usep = math.floor(_mem.inuse / _mem.total * 100)

0 commit comments

Comments
 (0)