diff options
author | Tim Keller <tjk@tjkeller.xyz> | 2024-10-17 22:32:17 -0500 |
---|---|---|
committer | Tim Keller <tjk@tjkeller.xyz> | 2024-10-17 22:32:17 -0500 |
commit | df86f7b92a3d0985d6d8c9ab1d027eeddb7b0443 (patch) | |
tree | b5e27ebd0cea42abee2b3ef0981087cd2c3a57eb /awesome/widgets/cpu.lua | |
parent | 572382a9ce99162bd93d2d6e3fd789f2c99bf420 (diff) | |
download | dotconfig-df86f7b92a3d0985d6d8c9ab1d027eeddb7b0443.tar.xz dotconfig-df86f7b92a3d0985d6d8c9ab1d027eeddb7b0443.zip |
remove awesome config, push to own repo
Diffstat (limited to 'awesome/widgets/cpu.lua')
-rw-r--r-- | awesome/widgets/cpu.lua | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/awesome/widgets/cpu.lua b/awesome/widgets/cpu.lua deleted file mode 100644 index d92bce8..0000000 --- a/awesome/widgets/cpu.lua +++ /dev/null @@ -1,38 +0,0 @@ -local wibox = require("wibox") -local widgets = require("util.widgets") - --- this is directly adapted from slstatus's cpu.c module -local cpu_time = { 0,0,0,0,0,0,0 } -- user, nice, system, idle, iowait, irq, softirq - -function linux_cpu_usage(widget) - -- read stat - local statf = io.open("/proc/stat") - local stat_iter = statf:read():gmatch("%d+") - statf:close() - - -- calc - local sum = 0 - local a, b = cpu_time, {} -- set cpu_time as a for smaller code - table.move(a, 1, 7, 1, b) -- copy first 7 to b - - for i = 1, 7 do - a[i] = stat_iter() - sum = sum + b[i] - a[i] - end - - if sum == 0 then - return - end - - local usage = ((b[1] + b[2] + b[3] + b[6] + b[7]) - - (a[1] + a[2] + a[3] + a[6] + a[7])) * 100 / sum - - widget:set_text(math.floor(usage)) -end - --- return correct widget for os -if osname == "Linux" then - return widgets.watchfn(linux_cpu_usage, 5) -end - -return wibox.widget.textbox("unsupported os") |