# fluxPowerControl

A Window Maker style power control dockapp for the Fluxbox slit. Displays an
IEC 5009 power icon or a padlock icon with a "PWR" header. Left-click locks the
screen, right-click runs a configurable command (screensaver settings, suspend,
etc.).

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

## Screenshot

```
┌──────────┐
│   PWR    │
│──────────│
│          │
│  (|)     │  ← power icon (or padlock)
│          │
└──────────┘
```

## Installation

Requires Rust and a working X11 environment.

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

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

## Usage

```
fluxPowerControl [OPTIONS]
```

Add `fluxPowerControl` 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 |
| `--icon power\|lock` | Icon style (default: power) |
| `--lock-command CMD` | Command to lock screen (left click) |
| `--right-click CMD` | Right click command |
| `--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 | Lock screen (`lock_command`) |
| Middle click | Run `middle_click` command (if configured) |
| Right click | Run `right_click` command (if configured) |

### Command auto-detection

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

**Lock command** (left click) probes for:
- i3lock, slock, swaylock
- xscreensaver-command -lock
- light-locker-command -l
- dm-tool lock
- loginctl lock-session
- xdg-screensaver lock

**Right click command** probes for:
- xscreensaver-demo
- gnome-control-center screen
- cinnamon-screensaver-preferences
- mate-screensaver-preferences
- xfce4-screensaver-preferences
- lxqt-config-screensaver
- systemctl suspend, loginctl suspend, pm-suspend, zzz

## Configuration

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

Generate an annotated config with auto-detected commands:

```sh
fluxPowerControl --write-config
```

Or use the interactive wizard:

```sh
fluxPowerControl --configure
```

### Config options

```ini
# 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

# Icon style: power or lock
icon = power

# Screen lock command (left click)
lock_command = i3lock

# Right click command
right_click = xscreensaver-demo

# Middle click command
middle_click = some-command

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

## Icon styles

- **power** (default) — IEC 5009 power symbol: circle with gap at top and vertical line
- **lock** — padlock: shackle arc with rectangular body and keyhole cutout

Set via `icon = lock` in config or `--icon lock` on the command line.

## License

[CC0 1.0](LICENSE) — Public Domain
