elenapan/config/awesome/evil/cpu.lua
elenapan c738169ca5 New theme: ephemeral, anti-aliased corners, app drawer, lock screen,
evil daemon system, dependency list update, README improvements.


Former-commit-id: db310f8e49
Former-commit-id: 4f25f9200c3ac9f9385daca5a68378249ff0329e
Former-commit-id: 69fa3954e5738446a59b409b7e326233e7c3ef55
Former-commit-id: 673176f7857e39f3455f4ccb426eef2789c0e891
2019-08-01 02:17:59 +03:00

18 lines
535 B
Lua

-- Provides:
-- evil::cpu
-- used percentage (integer)
local awful = require("awful")
local update_interval = 5
local cpu_idle_script = [[
sh -c "
vmstat 1 2 | tail -1 | awk '{printf \"%d\", $15}'
"]]
-- Periodically get cpu info
awful.widget.watch(cpu_idle_script, update_interval, function(widget, stdout)
-- local cpu_idle = stdout:match('+(.*)%.%d...(.*)%(')
local cpu_idle = stdout
cpu_idle = string.gsub(cpu_idle, '^%s*(.-)%s*$', '%1')
awesome.emit_signal("evil::cpu", 100 - tonumber(cpu_idle))
end)