Skip to content

Commit

Permalink
Merge pull request #59 from jgkamat/jay/memavailable
Browse files Browse the repository at this point in the history
Use MemAvailable for mem.free
  • Loading branch information
Mic92 authored Sep 28, 2018
2 parents a081bf7 + 0db5f3f commit 979cc46
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion widgets/mem_linux.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ local function worker(format)
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 == "MemAvailable" then _mem.buf.a = 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)
Expand All @@ -35,7 +36,7 @@ local function worker(format)
end

-- Calculate memory percentage
_mem.free = _mem.buf.f + _mem.buf.b + _mem.buf.c
_mem.free = _mem.buf.a
_mem.inuse = _mem.total - _mem.free
_mem.bcuse = _mem.total - _mem.buf.f
_mem.usep = math.floor(_mem.inuse / _mem.total * 100)
Expand Down

0 comments on commit 979cc46

Please sign in to comment.