# fluxMail

A Window Maker style mail notification dockapp for the Fluxbox slit. Monitors
local Maildir directories and displays unread message counts with a procedurally
drawn envelope icon. Shows up to 3 mailboxes simultaneously with per-directory
counts.

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

## Screenshot

```
┌──────────────┐
│         ✉    │  ← envelope icon (bright when any unread > 0)
│──────────────│
│ Local    200 │  ← mailbox 1: label left, count right
│ Gmail      1 │  ← mailbox 2
│ Work       0 │  ← mailbox 3 (dim when count is 0)
└──────────────┘
```

## Installation

Requires Rust and a working X11 environment.

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

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

## Usage

```
fluxMail [OPTIONS]
```

Add `fluxMail` 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 |
| `--maildir PATH` | Override first mail directory |
| `--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 | Open mail client (`left_click`) |
| Middle click | Refresh mail count (or run `middle_click` command) |
| Right click | Compose new email (`right_click`) |

### Mail directory auto-detection

Mail directories are detected in order:
1. `$MAILDIR` environment variable
2. `~/Maildir/`
3. `~/Mail/`
4. `~/.maildir/`
5. `~/.mail/`
6. `/var/mail/$USER`

Unread counting recursively finds all `new/` subdirectories and counts files,
handling both flat Maildirs and Maildir++ hierarchies.

### Command auto-detection

Commands are resolved in order: **CLI flag > config file > auto-detect**.

**Mail client** (left click) probes for:
- thunderbird, evolution, geary, claws-mail, sylpheed, kmail
- mutt, neomutt, alpine (via xterm)

**Compose** (right click) probes for:
- thunderbird -compose, evolution mailto:, geary mailto:
- claws-mail --compose, sylpheed --compose, kmail --composer
- xdg-email, mutt, neomutt (via xterm)

## Configuration

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

Generate an annotated config with auto-detected commands:

```sh
fluxMail --write-config
```

Or use the interactive wizard:

```sh
fluxMail --configure
```

### Config options

```ini
# Mail directories to monitor (up to 3, ~ expands to $HOME)
maildir1 = ~/Mail
label1 = Mail
maildir2 =
label2 =
maildir3 =
label3 =

# Check interval in seconds (minimum 5)
interval = 30

# 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: open mail client
left_click = thunderbird

# Middle click (default: refresh mail count)
middle_click =

# Right click: compose new email
right_click = thunderbird -compose

# 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)

## Multiple directories

Configure up to 3 mail directories. All configured directories are shown
simultaneously, one per line, with the label left-aligned and the unread count
right-aligned. Lines with zero unread messages are shown in the dim color.

## License

[CC0 1.0](LICENSE) — Public Domain
