commit d972b7e7fdcdab3121ed749ea2cc32d543d1bcd7 Author: XeonSquared Date: Thu Sep 8 00:18:15 2022 +1000 import diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..1dbee73 --- /dev/null +++ b/init.lua @@ -0,0 +1,59 @@ +local wibox = require("wibox") +local gears = require("gears") +local beautiful = require ("beautiful") +local rw = { + iconSize = 96, + iconPath = "/home/izaya/.config/awesome/awesome-memwidget" +} + + +function rw.new() + local stack = wibox.widget{ + layout = wibox.layout.stack, + } + local bgimage = wibox.widget{ + widget = wibox.widget.imagebox, + forced_width = rw.iconSize, + forced_height = rw.iconSize, + image = rw.iconPath .. "/media-memory.svg" + } + local rwidget = wibox.widget{ + layout = wibox.layout.grid.horizontal, + wibox.container.constraint(stack,nil,rw.iconSize,rw.iconSize) + } + local memtext = wibox.widget{ + align = 'center', + valign = 'bottom', + widget = wibox.widget.textbox + } + local membar = wibox.widget{ + widget = wibox.widget.progressbar, + max_value = 1, + border_width = 1, + border_color = beautiful.border_color, + color = beautiful.bg_focus, + background_color = beautiful.bg_normal, + forced_height = rw.iconSize / 6 + } + function rwidget.update() + local f = io.open("/proc/meminfo","rb") + if not f then return true end + local c = f:read("*a") + local total = tonumber(c:match("MemTotal:%s+(%d+)")) + local free = tonumber(c:match("MemFree:%s+(%d+)")) + local buffers = tonumber(c:match("Buffers:%s+(%d+)")) + local cache = tonumber(c:match("Cached:%s+(%d+)")) + local totalUsed = total - free + local used = totalUsed - (buffers + cache) + memtext.text = (string.format("%3.0f%%", (used/total)*100)) + membar.value = (used/total) + return true + end + stack:add(bgimage) + stack:add(wibox.container.place(membar,"center","bottom")) + stack:add(memtext) + rwidget.update() + return rwidget +end + +return rw diff --git a/media-memory.svg b/media-memory.svg new file mode 100644 index 0000000..48023ba --- /dev/null +++ b/media-memory.svg @@ -0,0 +1,1145 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +