Skip to main content

Ambient light-aware Ghostty theme selector with Bayesian preference learning

Project description

Ghostty Ambient

Ambient light-aware theme selector for Ghostty with Bayesian preference learning.

ghostty-ambient demo

Quick Install

curl -fsSL https://raw.githubusercontent.com/gezibash/ghostty-ambient/main/install.sh | bash

This installs the package and sets up the learning daemon to run automatically.

Features

  • Ambient Light Sensing: Reads your Mac's ambient light sensor to suggest themes appropriate for current lighting
  • Bayesian Learning: Learns your color preferences over time—which themes you prefer in different contexts
  • Context-Aware: Considers time of day, weather, system dark/light mode, and power source
  • Theme Generation: Generates custom themes from your learned preferences (background, contrast, saturation)
  • Portable Profiles: Export/import your learned preferences across devices

Installation

# Using uv (recommended)
uv add ghostty-ambient

# Using pip
pip install ghostty-ambient

Quick Start

Interactive Theme Picker

ghostty-ambient

Shows a picker with theme recommendations based on current conditions. Select a theme to apply it.

Run the Learning Daemon

ghostty-ambient --daemon

Runs in the background, learning your preferences by observing which themes you use in different contexts. Only records when Ghostty is the frontmost application.

Generate Your Ideal Theme

ghostty-ambient --ideal

Generates and applies a custom theme optimized for your current context, based on learned preferences:

  • Background color (light vs dark)
  • Contrast (how much difference between background and foreground)
  • Chroma (color saturation)

CLI Reference

ghostty-ambient              # Interactive theme picker
ghostty-ambient --ideal      # Generate and apply optimal theme
ghostty-ambient --set NAME   # Set theme by name
ghostty-ambient --stats      # Show learned preferences
ghostty-ambient --export-profile FILE  # Export preferences
ghostty-ambient --import-profile FILE  # Import preferences
ghostty-ambient --favorite   # Mark current theme as favorite
ghostty-ambient --dislike    # Mark current theme as disliked
ghostty-ambient --sensors    # Show available light sensors
ghostty-ambient --setup      # Configure location (for weather)

Daemon Management

ghostty-ambient --status              # Check daemon status
ghostty-ambient --start               # Start daemon (5m interval)
ghostty-ambient --start --freq 1m     # Start with custom interval
ghostty-ambient --stop                # Stop daemon
ghostty-ambient --restart             # Restart daemon
ghostty-ambient --logs                # Tail daemon logs

Run Daemon Inline

ghostty-ambient --daemon              # Run daemon in foreground
ghostty-ambient --daemon --interval 30s  # Custom interval

How It Works

Bayesian Preference Learning

The system learns three key properties of your theme preferences:

Property What It Learns
Background L Light vs dark theme preference (LAB lightness)
Contrast Preferred difference between background and foreground
Chroma Preferred color saturation in the palette

These are learned per-context:

  • Time of day (morning, afternoon, evening, night)
  • Ambient light (dim, office, bright, daylight)
  • System appearance (light mode, dark mode)
  • Power source (AC, battery)

View Your Learned Preferences

ghostty-ambient --stats
By Time of Day
╭───────────┬───────┬────┬──────────┬────────┬─────╮
│           │ Theme │  L │ Contrast │ Chroma │   n │
├───────────┼───────┼────┼──────────┼────────┼─────┤
│ Morning   │ light │ 97 │       84 │     49 │ 124 │
│ Afternoon │ light │ 97 │       86 │     50 │ 121 │
╰───────────┴───────┴────┴──────────┴────────┴─────╯

Portable Profiles

Export your learned preferences:

ghostty-ambient --export-profile ~/my-prefs.json

Import on another device:

ghostty-ambient --import-profile ~/my-prefs.json

Platform Support

Platform Ambient Light Sensor Theme Detection
macOS Native (via als helper) Full support
Linux Via iio-sensor-proxy Full support
Windows Via Windows SDK Partial support

macOS Ambient Light Sensor

The bundled als binary reads the ambient light sensor. To compile from source:

clang -framework IOKit -framework CoreFoundation als.m -o als

Daemon Management

The install script sets up a background daemon that learns your preferences. Use these commands to manage it:

ghostty-ambient --status              # Check if daemon is running
ghostty-ambient --start               # Start the daemon (default 5m interval)
ghostty-ambient --start --freq 30s    # Start with custom interval
ghostty-ambient --stop                # Stop the daemon
ghostty-ambient --restart             # Restart the daemon
ghostty-ambient --logs                # Tail daemon logs (Ctrl+C to exit)

Uninstall

curl -fsSL https://raw.githubusercontent.com/gezibash/ghostty-ambient/main/uninstall.sh | bash

Your learned preferences are preserved in ~/.config/ghostty-ambient/.

Development

# Clone and install dev dependencies
git clone https://github.com/gezibash/ghostty-ambient
cd ghostty-ambient
uv sync --all-extras

# Run tests
uv run pytest

# Run with verbose output
uv run ghostty-ambient --daemon --interval 30s

License

MIT License - see LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ghostty_ambient-0.8.3.tar.gz (62.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ghostty_ambient-0.8.3-py3-none-any.whl (75.3 kB view details)

Uploaded Python 3

File details

Details for the file ghostty_ambient-0.8.3.tar.gz.

File metadata

  • Download URL: ghostty_ambient-0.8.3.tar.gz
  • Upload date:
  • Size: 62.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for ghostty_ambient-0.8.3.tar.gz
Algorithm Hash digest
SHA256 1bd9ba98282fab3447bcda50e2f8be04a848589ae5691e6a6ceea8ab4d1473a1
MD5 fef44b0265324c0cd09995e5e0ab4d16
BLAKE2b-256 9c39e0d207f74f561d283443a2ec0daa47a3e56cc0548359d813b05e9746c8d6

See more details on using hashes here.

File details

Details for the file ghostty_ambient-0.8.3-py3-none-any.whl.

File metadata

  • Download URL: ghostty_ambient-0.8.3-py3-none-any.whl
  • Upload date:
  • Size: 75.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for ghostty_ambient-0.8.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b8f709e8b818fd7ade49eb483d5f497a3596726fdb1047318844c1616eace366
MD5 d8610ed253adb87cd7cc87e5f8f3ce2d
BLAKE2b-256 ad0184ce22e793670f8f4b7be9528b8cc8bd6b313ecce9f42364c2c2a39c88a8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page