# fluxCPU

A Window Maker style CPU monitor dockapp for the Fluxbox slit. Displays CPU
usage percentage with a horizontal bar graph and 1-minute load average.
Left-click shows a popup with per-core usage.

Part of the [Flux Dock Apps Suite](https://osugisakae.com/software/flux-dock-apps/).

## Screenshot

```
┌──────────────┐
│ CPU      42% │  ← overall CPU usage
│──────────────│
│ [████░░░░░░] │  ← usage bar graph
│ LOAD    1.23 │  ← 1-minute load average
└──────────────┘
```

## Installation

Requires Rust and a working X11 environment.

```sh
cargo build --release
cp target/release/fluxCPU ~/.local/bin/
```

The release build is stripped and LTO-optimized. No runtime dependencies beyond
libc and libX11.

## Usage

```
fluxCPU [OPTIONS]
```

Add `fluxCPU` to your Fluxbox startup to embed it in the slit.

### Options

| Flag | Description |
|---|---|
| `--size SIZE` | Window size: 64, 96 (default), or 128 pixels |
| `--font PATH` | Path to a TTF/OTF font file |
| `--interval SECS` | Update interval in seconds (minimum 1, default 2) |
| `--background`, `--bg` | Run in background |
| `--write-config [PATH]` | Write annotated config file and exit |
| `--configure` | Interactive configuration wizard |
| `--help` | Show help message |

### Click behavior

| Button | Action |
|---|---|
| Left click | Toggle per-core usage popup (or run `left_click` command) |
| Middle click | Run `middle_click` command (if configured) |
| Right click | Run `right_click` command (if configured) |

### Popup info

The left-click popup shows:
- Overall CPU usage percentage
- Load averages (1, 5, and 15 minute)
- Per-core usage percentages

### Data sources

- `/proc/stat` — CPU jiffies (total and per-core)
- `/proc/loadavg` — load averages

## Configuration

Config file: `~/.config/fluxCPU/config`

Generate an annotated config:

```sh
fluxCPU --write-config
```

Or use the interactive wizard:

```sh
fluxCPU --configure
```

### Config options

```ini
# Update interval in seconds (minimum 1)
interval = 2

# Window size: 64, 96, or 128 pixels
size = 96

# Font file path (leave unset for auto-detect via fontconfig)
font = /path/to/font.ttf

# Main color (R, G, B)
color = 0, 255, 0

# Dim color (R, G, B)
dim_color = 0, 200, 0

# Left click command (default: toggle per-core popup)
left_click =

# Middle click command
middle_click =

# Right click command
right_click =

# Run in the background
background = true
```

### Font discovery

Font is resolved in order:
1. `--font` flag or `font` config option
2. fontconfig (`fc-match monospace`)
3. Hardcoded paths (DejaVu Sans Mono, Liberation Mono, Noto Sans Mono)

## License

[CC0 1.0](LICENSE) — Public Domain
