awesome-wm-widgets/cpu-widget
Nuno Silva e791743eaf fix CI warnings
from https://github.com/streetturtle/awesome-wm-widgets/actions/runs/6915243510/job/18813967822?pr=421
2023-11-18 18:17:55 +00:00
..
README.md Fix documentation inconsistencies (mainly tables) 2023-09-20 23:01:55 +01:00
cpu-widget.lua fix CI warnings 2023-11-18 18:17:55 +00:00
cpu.gif update gif for cpu wodget 2020-02-20 21:36:29 -05:00
cpu.png Fix typo in filename 2022-05-24 16:57:23 +02:00
custom.png add screenshots of cpu widget 2019-06-02 22:06:25 -04:00
window-close-symbolic.svg Update readme and add an icon 2020-05-27 19:16:51 -04:00

README.md

CPU widget

GitHub issues by-label

This widget shows the average CPU load among all cores of the machine:

screenshot

How it works

To measure the load I took Paul Colby's bash script and rewrote it in Lua, which was quite simple. So awesome simply reads the first line of /proc/stat:

$ cat /proc/stat | grep '^cpu '
cpu  197294 718 50102 2002182 3844 0 2724 0 0 0

and calculates the percentage.

Customization

It is possible to customize widget by providing a table with all or some of the following config parameters:

Name Default Description
width 50 Width of the widget
step_width 2 Width of the step
step_spacing 1 Space size between steps
color beautiful.fg_normal Color of the graph
enable_kill_button false Show button which kills the process
process_info_max_length -1 Truncate the process information. Some processes may have a very long list of parameters which won't fit in the screen, this options allows to truncate it to the given length.
timeout 1 How often in seconds the widget refreshes

Example

cpu_widget({
    width = 70,
    step_width = 2,
    step_spacing = 0,
    color = '#434c5e'
})

The config above results in the following widget:

custom

Installation

Clone/download repo and use widget in rc.lua:

local cpu_widget = require("awesome-wm-widgets.cpu-widget.cpu-widget")
...
s.mytasklist, -- Middle widget
	{ -- Right widgets
    	layout = wibox.layout.fixed.horizontal,
		...
		-- default
		cpu_widget(),
		-- or custom
		cpu_widget({
            width = 70,
            step_width = 2,
            step_spacing = 0,
            color = '#434c5e'
        })
		...