dotfiles/.config/awesome/ui/top-panel/widgets/cpu.lua

47 lines
944 B
Lua
Raw Normal View History

2024-02-19 19:41:33 -08:00
local wibox = require("wibox")
2024-02-20 19:13:52 -08:00
local beautiful = require("beautiful").get()
local dpi = require("beautiful.xresources").apply_dpi
2024-02-19 19:41:33 -08:00
-- Icon
local icon = wibox.widget.textbox()
2024-02-19 19:41:33 -08:00
icon.font = beautiful.font_name .. "12.5"
icon.align = "center"
icon.markup = "<span foreground='" .. beautiful.xcolor9 .. "'></span>"
-- Uptime
local cpu = wibox.widget.textbox()
2024-02-19 19:41:33 -08:00
cpu.font = beautiful.font_name .. "10"
cpu.align = "center"
local function get_val()
awesome.connect_signal("signal::cpu", function(cpu_perc)
2024-02-20 19:13:52 -08:00
if cpu_perc then
cpu_perc = tonumber(cpu_perc)
else
cpu_perc = "?"
end
cpu.markup = cpu_perc .. "%"
2024-02-19 19:41:33 -08:00
end)
end
get_val()
2024-02-19 19:41:33 -08:00
local full = wibox.widget({
{
{
2024-02-19 19:41:33 -08:00
icon,
cpu,
spacing = dpi(8),
layout = wibox.layout.fixed.horizontal,
},
left = 1,
right = 0,
layout = wibox.container.margin,
},
2024-02-19 19:41:33 -08:00
forced_width = 73, -- Makes it fixed and not Moves Whole Bar
layout = wibox.layout.fixed.horizontal,
2024-02-19 19:41:33 -08:00
})
return full