Metadata-Version: 2.4
Name: lumitray
Version: 0.3.0
Summary: Privacy-preserving webcam-based automatic laptop brightness
Requires-Python: >=3.11
Description-Content-Type: text/markdown
Requires-Dist: numpy>=1.26
Requires-Dist: opencv-python-headless<5,>=4.8
Requires-Dist: psutil>=5.9
Requires-Dist: platformdirs>=4
Requires-Dist: Pillow>=10
Requires-Dist: pystray>=0.19
Requires-Dist: screen-brightness-control>=0.24
Requires-Dist: winsdk>=1.0.0b10; platform_system == "Windows" and python_version < "3.14"
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == "dev"

# LumiTray

LumiTray is a background Windows/Linux application that approximates ambient light with one low-resolution webcam frame and adjusts the built-in laptop display. It samples every **30 seconds on AC power** and every **5 minutes on battery or unknown power**.

## Privacy and accuracy

- Frames are processed in memory and are never saved.
- There is no recording, face detection, telemetry, or cloud service.
- The webcam is closed between measurements; its indicator may turn on briefly.
- A webcam is not a true ambient-light sensor. Use quick calibration and brightness bias to adapt the approximation to your laptop and room.
- Manual brightness changes pause automatic adjustment for 15 minutes.

## Install with pipx

Requires Python 3.11 or newer, including Python 3.14:

```bash
pipx install lumitray
lumitray install --autostart
```

`lumitray install` creates a per-user Start Menu shortcut on Windows or application entry on Linux. `--autostart` also starts LumiTray at login. No administrator privileges are required.

To remove launchers while preserving settings:

```bash
lumitray uninstall
pipx uninstall lumitray
```

## Standalone Windows and Linux packages

Download `lumitray-windows.zip` or `lumitray-linux.tar.gz` from the GitHub release and extract both executables. No system Python is required.

On Windows:

```powershell
.\lumitray.exe install --autostart
.\lumitray-tray.exe
```

On Linux:

```bash
./lumitray install --autostart
./lumitray-tray
```

Linux requires a V4L2-compatible webcam, a supported tray/AppIndicator environment, and `brightnessctl` with user-writable backlight permissions. Python-based Linux installations also need Tk support for the settings dialog. The installers do not change system permissions.

## Settings

Right-click the tray icon and choose **Settings…**, or run:

```bash
lumitray settings
lumitray settings --min 70 --max 100
lumitray settings --min 75
lumitray settings --max 90
```

Defaults are **70–100%**. Limits must be integers satisfying `5 <= minimum < maximum <= 100`. Invalid updates leave the existing configuration untouched. Saving from the tray applies the settings immediately when automatic adjustment is active; paused and disabled states are preserved. Camera frames are never saved.

## Commands

```bash
# Check platform, power source, and brightness support
lumitray diagnose

# Capture one frame and print only numeric luminance
lumitray sample

# Run one automatic adjustment cycle
lumitray once

# Change brightness slightly, verify it, then restore the original value
lumitray brightness-test --delta 5

# Create or remove per-user application launchers
lumitray install [--autostart]
lumitray uninstall

# Run in the background tray
lumitray tray
```

When running from the project without adding the console script to `PATH`, use `.venv\Scripts\python.exe -m lumitray ...` on Windows or `.venv/bin/python -m lumitray ...` on Linux.

## Tray controls

The tray menu provides status, pause/resume, brightness bias, settings, quick calibration, automatic-adjustment enable/disable, login autostart, and Exit. Only one tray instance can run at a time.

## Ambient-light response

The generic response interpolates between these normalized camera-luminance anchors:

| Camera-relative luminance | Target before bias and user limits |
| --- | --- |
| 0.00 | 20% |
| 0.08 | 25% |
| 0.20 | 40% |
| 0.40 | 55% |
| 0.60 | 70% |
| 0.80 | 85% |
| 1.00 | 95% |

The curve is inspired by adaptive-brightness research, but normalized camera luminance is **not measured lux**. Webcam exposure, gain, direction, and scene content vary. Quick calibration, brightness bias, smoothing, a deadband, and maximum-step limits let LumiTray adapt without abrupt changes.

Research references:

- Microsoft adaptive-brightness guidance: https://learn.microsoft.com/en-us/windows-hardware/design/device-experiences/sensors-adaptive-brightness
- Controlled screen-brightness study: https://jps.ecnu.edu.cn/EN/abstract/abstract9078.shtml
- Example of device-specific webcam/lux calibration: https://www.medrxiv.org/content/10.1101/2020.05.28.20115725v2.full-text

## Platform details

On Windows with Python 3.11–3.13, LumiTray uses native WinRT `MediaCapture` through `winsdk`, captures a 320 × 240 JPEG directly into memory, and closes the capture session after every sample. Python 3.14 uses OpenCV because `winsdk` does not yet provide Python 3.14 binaries. OpenCV is also the camera backend on Linux.

Linux standalone artifacts are built and CLI-smoke-tested in native CI; they are not hardware-verified from a Windows development machine.

## Configuration and logs

Settings and logs are stored in the platform-specific user configuration/log directories reported by `platformdirs`. Configuration is JSON. Logs contain numeric status and error information, never images.

## Development verification

```bash
python -m venv .venv
.venv/Scripts/python -m pip install -e ".[dev]"  # Windows
.venv/Scripts/python -m pytest -q                 # Windows
.venv/Scripts/python -m build
```

The automated suite uses fake hardware. Real display verification is performed only by the explicit `brightness-test` command, which restores the original value in a `finally` path.

## Limitations

External monitors, macOS, and every OEM-specific display driver are not guaranteed in this release. Long-duration battery-drain measurements require separate testing on each supported laptop model.
