awesome-wm-widgets/cpu-widget/README.md

35 lines
899 B
Markdown
Raw Normal View History

2017-09-28 01:45:25 +02:00
# CPU widget
This widget shows the average CPU load among all cores of the machine:
2017-09-28 01:48:08 +02:00
![screenshot](out.gif)
2017-09-28 01:45:25 +02:00
When the load is more than 80% the graph becomes red. You can easily customize the widget by changing colors, step width, step spacing, width and interval.
## How it works
2017-09-28 15:39:16 +02:00
To measure the load I took Paul Colby's bash [script](http://colby.id.au/calculating-cpu-usage-from-proc-stat/) and rewrote it in Lua, which was quite simple.
2017-09-28 01:45:25 +02:00
So awesome simply reads the first line of /proc/stat:
```bash
$ cat /proc/stat | grep '^cpu '
cpu 197294 718 50102 2002182 3844 0 2724 0 0 0
```
and calculates the percentage.
## Installation
Clone/download repo and use widget in **rc.lua**:
```lua
local cpu_widget = require("awesome-wm-widgets.cpu-widget.cpu-widget")
2017-09-28 01:45:25 +02:00
...
s.mytasklist, -- Middle widget
{ -- Right widgets
layout = wibox.layout.fixed.horizontal,
...
cpu_widget,
...
2017-09-28 01:48:08 +02:00
```