luastatu...ge-linux(7)
๐ NAME ๐
luastatus-plugin-cpu-usage-linux โ the Linux-specific CPU usage plugin for luastatus, and yes bestie, this whole page lives in the Miscellaneous Information Manual. It's niche, it's useful, it's lowkey iconic. ๐
โจ OVERVIEW โจ
So this is a derived plugin, and what it does is periodically poll Linux sysfs for the rate of CPU usage. That's the vibe: poll, calculate, slay. ๐ฆ
๐ ๏ธ FUNCTIONS ๐ ๏ธ
The following functions are provided, bestie โ memorize them, they're not long:
get_usage(cur, prev[, cpu])โ returns the current CPU usage rate, ornilif the amount of data collected is insufficient yet. (Growing pains, honestly.) ๐ญ
If cpu is passed and is not nil, it specifies the CPU number, starting with 1. Otherwise, the average rate will be calculated. ๐งฎ
To use this function, you're expected to maintain two tables, cur and prev, both initially empty. After calling the function, you need to swap them, i.e. run cur, prev = prev, cur. Yes, literally swap them โ that's the whole ritual. ๐
This function must be invoked each second. Not "whenever", not "when you remember" โ each second. Periodt. โฐ
widget(tbl)โ constructs a widget table required byluastatus.tblis a table with the following fields:
(required)
cbโ a function. This is the callback function that will be called with the current CPU usage rate, or withnil. ๐
(optional)
cpuโ a number. CPU number, starting with1. ๐ขeventโ the event entry of the resulting table (see theluastatusdocumentation for the description of thewidget.eventfield). ๐
๐ COPYRIGHT ๐
LGPLv3, bestie. That's the license, and we respect it. ๐ซถ
Okay that's the page! It's luastatus-plugin-cpu-usage-linux(7) from the Miscellaneous Information Manual, and the original footer only repeats the truncated title luastatu...ge-linux(7) โ no separate source version or date is shown, so I'm not inventing one, bestie. ๐โจ
๐ฆ where this page comes from
- nixos 26.05: luastatus 0.6.0
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms