Adapted for system without swap
This commit is contained in:
parent
eff92f7e09
commit
03e7d5360c
|
@ -36,23 +36,23 @@ w:setup {
|
||||||
widget = wibox.widget.piechart
|
widget = wibox.widget.piechart
|
||||||
}
|
}
|
||||||
|
|
||||||
local total, used, free, shared, buff_cache, available, total_swap, used_swap, free_swap
|
local total, used, free, shared, buff_cache, available
|
||||||
|
|
||||||
local function getPercentage(value)
|
local function getPercentage(value)
|
||||||
return math.floor(value / (total+total_swap) * 100 + 0.5) .. '%'
|
return math.floor(value / (total) * 100 + 0.5) .. '%'
|
||||||
end
|
end
|
||||||
|
|
||||||
watch('bash -c "free | grep -z Mem.*Swap.*"', 1,
|
watch('bash -c "free | grep -z Mem"', 1,
|
||||||
function(widget, stdout, stderr, exitreason, exitcode)
|
function(widget, stdout, stderr, exitreason, exitcode)
|
||||||
total, used, free, shared, buff_cache, available, total_swap, used_swap, free_swap =
|
total, used, free, shared, buff_cache, available =
|
||||||
stdout:match('(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*Swap:%s*(%d+)%s*(%d+)%s*(%d+)')
|
stdout:match('(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*(%d+)')
|
||||||
|
|
||||||
widget.data = { used, total-used } widget.data = { used, total-used }
|
widget.data = { used, total-used } widget.data = { used, total-used }
|
||||||
|
|
||||||
if w.visible then
|
if w.visible then
|
||||||
w.pie.data_list = {
|
w.pie.data_list = {
|
||||||
{'used ' .. getPercentage(used + used_swap), used + used_swap},
|
{'used ' .. getPercentage(used), used},
|
||||||
{'free ' .. getPercentage(free + free_swap), free + free_swap},
|
{'free ' .. getPercentage(free), free},
|
||||||
{'buff_cache ' .. getPercentage(buff_cache), buff_cache}
|
{'buff_cache ' .. getPercentage(buff_cache), buff_cache}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -65,8 +65,8 @@ ramgraph_widget:buttons(
|
||||||
awful.button({}, 1, function()
|
awful.button({}, 1, function()
|
||||||
awful.placement.top_right(w, { margins = {top = 25, right = 10}, parent = awful.screen.focused() })
|
awful.placement.top_right(w, { margins = {top = 25, right = 10}, parent = awful.screen.focused() })
|
||||||
w.pie.data_list = {
|
w.pie.data_list = {
|
||||||
{'used ' .. getPercentage(used + used_swap), used + used_swap},
|
{'used ' .. getPercentage(used), used},
|
||||||
{'free ' .. getPercentage(free + free_swap), free + free_swap},
|
{'free ' .. getPercentage(free), free},
|
||||||
{'buff_cache ' .. getPercentage(buff_cache), buff_cache}
|
{'buff_cache ' .. getPercentage(buff_cache), buff_cache}
|
||||||
}
|
}
|
||||||
w.pie.display_labels = true
|
w.pie.display_labels = true
|
||||||
|
|
Loading…
Reference in New Issue