From 36b45cb895303f4b8bdd99a737259740129e1fb9 Mon Sep 17 00:00:00 2001 From: Timmy Keller Date: Tue, 17 Sep 2024 19:17:49 -0500 Subject: add current awesome configs --- awesome/widgets/ram.lua | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 awesome/widgets/ram.lua (limited to 'awesome/widgets/ram.lua') diff --git a/awesome/widgets/ram.lua b/awesome/widgets/ram.lua new file mode 100644 index 0000000..2347ca4 --- /dev/null +++ b/awesome/widgets/ram.lua @@ -0,0 +1,36 @@ +local wibox = require("wibox") +local widgets = require("util.widgets") +local osname = require("util.osname") + + +function linux_ram_usage(widget) + -- read meminfo + local meminfof = io.open("/proc/meminfo") + + local total = meminfof:read():match("%d+") + local free = meminfof:read():match("%d+") + + meminfof:read() -- memavailable not used + + local buffers = meminfof:read():match("%d+") + local cached = meminfof:read():match("%d+") + + meminfof:close() + + -- calc + if total == nil then + return + end + + local used = (total - free - buffers - cached) * 100 / total + + widget:set_text(math.floor(used)) +end + + +-- return correct widget for os +if osname == "Linux" then + return widgets.watchfn(linux_ram_usage, 5) +end + +return wibox.widget.textbox("unsupported os") -- cgit v1.2.3