summaryrefslogtreecommitdiff
path: root/ram-widget
diff options
context:
space:
mode:
authorpmakhov <pavel.makhov@savoirfairelinux.com>2017-12-11 17:08:55 -0500
committerpmakhov <pavel.makhov@savoirfairelinux.com>2017-12-11 17:08:55 -0500
commit6539d81b5caeb11604186b2ae1d9430ba0fcd9f0 (patch)
treedcf8489bbff98fc2b428b1ac2d0fae068d4207e3 /ram-widget
parentd94e05bda0f24173fb8c6c3513cbae1d082e5a74 (diff)
ram widget wip
Diffstat (limited to 'ram-widget')
-rw-r--r--ram-widget/ram-widget.lua72
1 files changed, 72 insertions, 0 deletions
diff --git a/ram-widget/ram-widget.lua b/ram-widget/ram-widget.lua
new file mode 100644
index 0000000..e0a4dea
--- /dev/null
+++ b/ram-widget/ram-widget.lua
@@ -0,0 +1,72 @@
+local awful = require("awful")
+local watch = require("awful.widget.watch")
+local wibox = require("wibox")
+
+local ramgraph_widget = wibox.widget {
+ border_width = 0,
+ colors = {
+ '#74aeab', '#26403f'
+ },
+ display_labels = false,
+ forced_width = 25,
+ widget = wibox.widget.piechart
+}
+
+local total, used, free, shared, buff_cache, available
+
+watch('bash -c "free | grep Mem"', 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+)')
+
+ widget.data = {used, total-used}
+ end,
+ ramgraph_widget
+)
+
+local w = wibox {
+ height = 200,
+ width = 350,
+ ontop = true,
+ screen = mouse.screen,
+ expand = true,
+ bg = '#1e252c',
+ max_widget_size = 500
+}
+
+w:setup {
+ border_width = 0,
+ colors = {
+ '#74aeab',
+ '#6eaaa7',
+ '#5ea19d',
+ '#55918e',
+ '#4b817e',
+ },
+ display_labels = false,
+ forced_width = 25,
+ id = 'pie',
+ widget = wibox.widget.piechart
+}
+
+ramgraph_widget:buttons(
+ awful.util.table.join(
+ awful.button({}, 1, function()
+ awful.placement.top_right(w, { margins = {top = 25, right = 10}})
+ w.pie.data_list = {
+ {'used' , used},
+ {'free' , free},
+ {'shared' , shared},
+ {'buff_cache' , buff_cache},
+ {'available' , available
+ }
+ }
+ w.pie.display_labels = true
+ w.visible = true
+ end),
+ awful.button({}, 3, function()
+ w.visible = false;
+ end)
+ )
+)
+
+return ramgraph_widget