diff options
author | streetturtle <streetturtle@users.noreply.github.com> | 2018-04-15 14:19:22 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-15 14:19:22 -0400 |
commit | 70790737e5f12c063dbff29af47e4d421a94e0f1 (patch) | |
tree | 2cdb77ba29f8cc1cd33fa5532349ed9189754ba4 /ram-widget | |
parent | 531883c62ee28794b67d9334369737c99ad7dfe4 (diff) | |
parent | 3384f0f4eacd68b867539743e9b6bcbdd7d5f836 (diff) |
Merge pull request #43 from marc-queiroz/master
Including Swap to raw-widget
Diffstat (limited to 'ram-widget')
-rw-r--r-- | ram-widget/ram-widget.lua | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/ram-widget/ram-widget.lua b/ram-widget/ram-widget.lua index b378990..257f0b4 100644 --- a/ram-widget/ram-widget.lua +++ b/ram-widget/ram-widget.lua @@ -37,21 +37,21 @@ w:setup { widget = wibox.widget.piechart } -local total, used, free, shared, buff_cache, available +local total, used, free, shared, buff_cache, available, total_swap, used_swap, free_swap local function getPercentage(value) - return math.floor(value / total * 100 + 0.5) .. '%' + return math.floor(value / (total+total_swap) * 100 + 0.5) .. '%' end -watch('bash -c "free | grep Mem"', 1, +watch('bash -c "free | grep -z Mem.*Swap.*"', 1, function(widget, stdout, stderr, exitreason, exitcode) - total, used, free, shared, buff_cache, available = stdout:match('(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*(%d+)') + total, used, free, shared, buff_cache, available, total_swap, used_swap, free_swap = stdout:match('(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*Swap:%s*(%d+)%s*(%d+)%s*(%d+)') widget.data = { used, total-used } if w.visible then w.pie.data_list = { - {'used ' .. getPercentage(used), used}, - {'free ' .. getPercentage(free), free}, + {'used ' .. getPercentage(used+used_swap), used+used_swap}, + {'free ' .. getPercentage(free+free_swap), free+free_swap}, {'buff_cache ' .. getPercentage(buff_cache), buff_cache} } end @@ -64,8 +64,8 @@ ramgraph_widget:buttons( awful.button({}, 1, function() awful.placement.top_right(w, { margins = {top = 25, right = 10}}) w.pie.data_list = { - {'used ' .. getPercentage(used), used}, - {'free ' .. getPercentage(free), free}, + {'used ' .. getPercentage(used+used_swap), used+used_swap}, + {'free ' .. getPercentage(free+free_swap), free+free_swap}, {'buff_cache ' .. getPercentage(buff_cache), buff_cache} } w.pie.display_labels = true |