luastatu...ge-linux(7)

๐Ÿ“ฆ
version 0.6.0 ยท 2 versions
, in nixos 26.05

๐Ÿ’– 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, or nil if 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 by luastatus. tbl is 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 with nil. ๐Ÿ“ž

(optional)

  • cpu โ€” a number. CPU number, starting with 1. ๐Ÿ”ข
  • event โ€” the event entry of the resulting table (see the luastatus documentation for the description of the widget.event field). ๐Ÿ‘€

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