From 5d346892b87487f3e7011e845328a607b0521ef7 Mon Sep 17 00:00:00 2001 From: Marc Queiroz Date: Fri, 13 Apr 2018 10:40:10 -0300 Subject: Including Swap to Ram calculations --- ram-widget/ram-widget.lua | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'ram-widget') diff --git a/ram-widget/ram-widget.lua b/ram-widget/ram-widget.lua index b378990..edf9dd4 100644 --- a/ram-widget/ram-widget.lua +++ b/ram-widget/ram-widget.lua @@ -1,6 +1,7 @@ local awful = require("awful") local watch = require("awful.widget.watch") local wibox = require("wibox") +local gd = require("gears.debug") --- Main ram widget shown on wibar local ramgraph_widget = wibox.widget { @@ -37,21 +38,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 +65,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 -- cgit v1.2.3 From 3384f0f4eacd68b867539743e9b6bcbdd7d5f836 Mon Sep 17 00:00:00 2001 From: Marc Queiroz Date: Fri, 13 Apr 2018 10:41:51 -0300 Subject: Removing unused library --- ram-widget/ram-widget.lua | 1 - 1 file changed, 1 deletion(-) (limited to 'ram-widget') diff --git a/ram-widget/ram-widget.lua b/ram-widget/ram-widget.lua index edf9dd4..257f0b4 100644 --- a/ram-widget/ram-widget.lua +++ b/ram-widget/ram-widget.lua @@ -1,7 +1,6 @@ local awful = require("awful") local watch = require("awful.widget.watch") local wibox = require("wibox") -local gd = require("gears.debug") --- Main ram widget shown on wibar local ramgraph_widget = wibox.widget { -- cgit v1.2.3