Skip to content

CodeByHardik/Smart-Brightness

Repository files navigation

🌟 Smart Brightness

Rust License GitHub stars

A lightweight, real-time automatic screen brightness adjustment tool for Linux that uses your webcam as an ambient light sensor. Inspired by mobile device auto-brightness, but built for your Linux desktop/laptop.

✨ Features

  • 🌈 Perceived Dominance Sensing: Intelligent luma estimation that favors diffuse environmental light over punctual sources (like lamps) using weighted histograms.
  • ⚡ Lightweight and resource-efficient with half-precision optimization
  • 🎯 Custom calibration for optimal accuracy
  • ⚙️ Deeply configurable via TOML
  • 🌙 Built-in circadian rhythm support (optimizes brightness based on time of day)
  • 📊 Detailed logging and status monitoring
  • 🚀 Actively developed and optimized for performance

🚀 Quick Start

Prerequisites

  • Rust (latest stable)
  • Linux system with a webcam
  • Backlight control support (/sys/class/backlight)

Installation

  1. Clone the repository

    git clone https://github.com/CodeByHardik/Smart-Brightness.git
    cd Smart-Brightness
  2. Run the Interactive Installer

    chmod +x install.sh
    ./install.sh

    The installer will guide you through:

    • Installing dependencies and permissions
    • Selecting a daemon mode (Realtime, Boot, or Interval)
    • Running initial calibration
    • Setting up the systemd service

🛠️ Usage

Configuration

You can configure Smart Brightness in two ways:

  1. Interactive TUI (Recommended)

    smart-brightness --configure

    This opens a visual interface to edit settings, change modes, and adjust sensitivity.

  2. Manual Config Editing Edit ~/.config/smart-brightness/config.toml directly.

For a detailed explanation of all options, see the Configuration Guide. For a deep dive into the math and algorithms, see the Internal Logic Guide.

Calibration

If you notice the brightness range is limited or ambient detection is off:

smart-brightness --calibrate

Daemon Modes

  • Realtime: Continuously adjusts brightness. Best for most users.
  • Boot: Runs for a set duration (e.g. 5 mins) after login, then exits. Good for quick adjustment on startup without background resource usage.
  • Interval: Runs for a duration, sleeps, then repeats. Good balance of power saving and responsiveness.

Configuration files are present in the following locations:

/etc/smart-brightness/config.toml
~/.config/smart-brightness/config.toml

Monitor Brightness

watch -n 1 cat /sys/class/backlight/*/actual_brightness

📊 Monitoring

View real-time status:

journalctl -f -u smart-brightness  # If running as a service
# OR
RUST_LOG=info ./target/release/smart_brightness

🛣️ Roadmap

Core Features

  • Basic auto-brightness functionality
  • Configuration via TOML
  • Calibration tool
  • Systemd service daemon
  • Systemd daemon fixes
  • Enhancing the installation process
  • Widen the scope of configuration

Advanced Features

  • Face detection integration

Made with ❤️ by CodeByHardik

About

Adaptive ambient brightness controller for Linux using the webcam.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors