2024-02-18 20:26:15 -08:00
|
|
|
local awful = require "awful"
|
|
|
|
local gears = require "gears"
|
|
|
|
|
2024-02-18 14:31:14 -08:00
|
|
|
|
|
|
|
local function get_cpu()
|
|
|
|
local script = [[
|
2024-02-18 20:26:15 -08:00
|
|
|
echo $[100-$(vmstat 1 2|tail -1|awk '{print $15}')]
|
|
|
|
]]
|
2024-02-18 14:31:14 -08:00
|
|
|
|
|
|
|
awful.spawn.easy_async_with_shell(script, function(cpu_perc)
|
|
|
|
cpu_perc = cpu_perc:match("%d+")
|
|
|
|
awesome.emit_signal("signal::cpu", cpu_perc)
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
2024-02-18 20:26:15 -08:00
|
|
|
gears.timer {
|
2024-02-18 14:31:14 -08:00
|
|
|
timeout = 1,
|
|
|
|
call_now = true,
|
|
|
|
autostart = true,
|
|
|
|
callback = function()
|
|
|
|
get_cpu()
|
2024-02-18 20:26:15 -08:00
|
|
|
end
|
|
|
|
}
|