# fluxNetwork

A Window Maker style network monitor dockapp for the Fluxbox slit. Displays
real-time download and upload speeds for a network interface by reading kernel
byte counters from `/sys/class/net/`.

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

## Screenshot

```
┌──────────────┐
│ NET    enp5s0│  ← header: "NET" left, interface name right (dim)
│──────────────│
│ DN      1.2M │  ← download speed (bright when active)
│ UP       45K │  ← upload speed (bright when active)
└──────────────┘
```

## Installation

Requires Rust and a working X11 environment.

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

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

## Usage

```
fluxNetwork [OPTIONS]
```

Add `fluxNetwork` 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 |
| `--interface IFACE` | Network interface to monitor |
| `--background`, `--bg` | Run in background |
| `--write-config [PATH]` | Write annotated config file and exit |
| `--configure` | Interactive configuration wizard |
| `--help` | Show help message |

### Click behavior

All three click actions are user-configured via config file or `--configure`.

| Button | Action |
|---|---|
| Left click | Run `left_click` command |
| Middle click | Run `middle_click` command |
| Right click | Run `right_click` command |

### Interface auto-detection

The network interface is resolved in order:
1. `--interface` CLI flag
2. `interface` config option
3. Default route from `/proc/net/route`
4. First non-`lo` interface in `/sys/class/net/`

### Speed format

Speeds are displayed as bytes per second with auto-scaling:
- `0` — idle (0 B/s)
- `123B` — bytes/sec (< 1024)
- `1.2K` — kilobytes/sec (< 1024K)
- `4.5M` — megabytes/sec (< 1024M)
- `1.1G` — gigabytes/sec

## Configuration

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

Generate an annotated config:

```sh
fluxNetwork --write-config
```

Or use the interactive wizard:

```sh
fluxNetwork --configure
```

### Config options

```ini
# Network interface (auto-detected if not set)
interface = enp5s0

# 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

# Click commands
# Suggestions: nm-connection-editor, nmtui, wireshark, iftop
left_click =
middle_click =
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
