# fluxData

Shared astronomy and weather data daemon for the Flux Dock Apps Suite. Fetches
moon/sun data from the USNO API and weather from Open-Meteo, writing atomic JSON
for other flux apps to read.

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

## Installation

Requires Rust and `curl` at runtime for HTTP requests.

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

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

## Usage

```
fluxData [OPTIONS]
```

Run `fluxData` before starting other flux apps that depend on it (fluxMoon, etc.).

### Options

| Flag | Description |
|---|---|
| `--background`, `--daemon`, `--bg` | Fork to background after setup |
| `--once` | Fetch once and exit |
| `--verbose`, `-v` | Show informational messages (quiet by default) |
| `--write-config [PATH]` | Write annotated config file and exit |
| `--configure` | Interactive configuration wizard |
| `--help` | Show help message |

### Output

Data is written to `~/.local/share/fluxData/data.json` as pretty-printed JSON
containing:
- **location**: latitude, longitude
- **moon**: phase name, illumination, rise/set/transit, next new/full moon
- **sun**: rise/set/transit, civil twilight begin/end
- **weather**: temperature, humidity, wind, pressure, cloud cover

### Location detection

Location is resolved in order:
1. `latitude`/`longitude` in config file
2. Cached location from previous `data.json`
3. IP geolocation via ip-api.com (prompts to save to config)

## Configuration

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

Generate an annotated config:

```sh
fluxData --write-config
```

Or use the interactive wizard:

```sh
fluxData --configure
```

### Config options

```ini
# Latitude (decimal degrees, positive = north)
latitude = 40.7128

# Longitude (decimal degrees, positive = east)
longitude = -74.0060

# Fetch interval in minutes
interval = 30

# Run as background daemon
background = true

# Show informational messages (quiet by default)
# verbose = true
```

### PID file

When running as a daemon, fluxData writes its PID to
`~/.local/share/fluxData/fluxData.pid` and removes it on clean shutdown.

### Signal handling

fluxData handles SIGTERM and SIGINT for clean shutdown (removes PID file).

## License

[CC0 1.0](LICENSE) — Public Domain
