Skip to content

RobChiocchio/illuminanced

 
 

Repository files navigation

Ambient Light Sensor Daemon for Linux

A user-space daemon that automatically adjusts screen brightness based on light sensor readings.

Testing Before Installation

First, identify the light sensor device path, try to run from a terminal find /sys/bus -name in_illuminance_raw. In some cases the device name can be significantly different, try to broaden the search: find /sys/bus -name '*illuminance*'. When you have found a device, check that it works, for example: sudo watch cat /sys/bus/acpi/devices/ACPI0008\:00/iio\:device0/in_illuminance_raw. The readings should be changing (try closing the sensor or add more light). If the number is still the same it means the sensor driver doesn't work properly.

For ZBook 15 G6, Framework laptops, and maybe others, the sensor path is /sys/bus/iio/devices/iio:device0/in_illuminance_raw.

You need to put the device path to the config before starting the daemon. On some laptops, the device name can be different after each reboot, you can use * in the device path in the config.

Supported laptops

Works on ASUS Zenbooks with built-in driver acpi-als:

  • UX303UB
  • UX305LA
  • UX305FA
  • UX310UQ
  • UX330UA

Also works on Framework laptops:

  • Framework 13 AMD
  • Framework 16 AMD

Install deb package

Download the deb package from the last release.

To install and start run next commands after download:

sudo dpkg -i ~/Download/illuminanced_1.0-0.deb
# change config if device path is different
sudo systemctl enable illuminanced.service
sudo systemctl start illuminanced.service

You can check status by running systemctl status illuminanced.service

Build & install

  • install Rust: curl https://sh.rustup.rs -sSf | sh
  • clone : git clone https://github.com/mikhail-m1/illuminanced.git
  • build: cd illuminanced; cargo build --release
  • change device path if needed
  • install sudo ./install.sh

Troubleshooting

If the service fails to start, try to run it in foreground mode to see what is wrong: sudo /usr/local/sbin/illuminanced -d.

How to Adjust

  • open a config file /usr/local/etc/illuminanced.toml (Default)
  • choose how many light values do you need by [general].light_steps
  • set defined points count by [light].points_count
  • set each point by illuminance_<n> and light_<n> where illuminance from in_illuminance_raw (see below) and light in range [0..light_steps)

How it works

The daemon reads illuminance from /sys/bus/acpi/devices/ACPI0008:00/iio:device0/in_illuminance_raw, applies a Kalman filter for noise reduction, and sets backlight brightness based on configured light points.

The process flow:

  1. Sensor reading: Raw illuminance value from the ambient light sensor
  2. Kalman filtering: Smooths out sensor noise to prevent brightness flickering
  3. Light conversion: Maps illuminance to a normalized brightness level (0 to light_steps)
  4. Discrete steps: Converts normalized level to hardware brightness value with hysteresis to prevent rapid changes
  5. Hardware update: Writes the final brightness value to the backlight device

Kalman Filter

The Kalman filter prevents brightness flickering caused by noisy sensor readings. Even when ambient light is stable, sensors often produce fluctuating values (e.g., 28, 31, 29, 32...). The filter maintains a smoothed estimate by:

  • Weighing new measurements against the current estimate
  • Adjusting gradually rather than jumping to every reading
  • Using configurable parameters in [kalman] section:
    • q: Process noise (how much the true value can change)
    • r: Measurement noise (how noisy the sensor is - higher values = more smoothing)
    • covariance: Initial uncertainty estimate

Anti-flicker Protection

In addition to Kalman filtering, the daemon uses two mechanisms to prevent brightness changes from small variations:

  • Barrier threshold: Changes must exceed step_barrier (default 0.1) to trigger an update
  • Discrete steps: Brightness is quantized into light_steps discrete levels rather than continuous adjustment

Unfortunately, I cannot find a way how to get events from iio buffers, for acpi-als driver, so the daemon checks the value every second.

Switch modes

My laptop has a special key to control brightness, which sends KEY_ALS_TOGGLE 0x230 /* Ambient light sensor */ code. The daemon monitors it to switch between different modes. You can redefine the key by changing event_device_name and switch_key_code. showkey and evtest can help to find the code and device name.

The key switches between next three modes:

  • Auto adjust
  • Disabled
  • Max brightness (useful for movies, can be disabled by config file /usr/local/etc/illuminanced.toml)

About

Ambient Light Sensor Daemon for Linux

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Rust 96.4%
  • Shell 3.6%