Automation tool for certain Lenovo ThinkPad laptops (ex. X1c, X1e, P1) to control the keyboard backlight and lcd screen brightness (backlight) on Windows installations using a system-tray application. These laptops do not come with an automatic control mechanism for either. Additional behaviors added by this program mimic some automations found on other devices. Keyboard backlight control is triggerred by a user-activity timeout, and screen backlight control samples the ambient light level using the integrated camera.
This project provides a background Windows system tray application that augments the keyboard and lcd screen backlight controls through software. Settings supporting these two features are configurable through the GUI context menu (right-click) on the system tray. They can be individually disabled or enabled.
The keyboard backlight is automatically illuminated whenever the user interacts with the built-in keyboard/mouse hardware. After an adjustable inactivity timeout, the backlight is darkened. The keyboard brightness level changes along with the existing "Fn+Space" keyboard shortcut for backlight level. Settings are persisted across power events (sleep/wake, display on/off) for a hands-off experience, unlike the stock factory behavior which resets backlight across power events.
The screen backlight is automatically illuminated by sampling the integrated camera to mimic an ambient light sensor. A basic-low resolution snapshot is taken and the average intensity level is computed to use as the proxy for ambient light level. The level is mapped to a screen brightness percentage using a configurable calibration curve. The sampling and updating process will be triggered by a power event (sleep/wake, display on/off) or by user activity timeout on the built-in keyboard/mouse. This keeps the backlight ready on first-use. Optionally, a periodic sampling interval can be specified. However, this can be distracting due to the activity LED built-in on the camera. This application will only sample the camera at predicatable events (power events, user activity timeout) to minimize the distraction. A configurable hotkey (default: Alt-Space) can also trigger screen backlight refresh, for when the user is moving to different lighting conditions.
Go to the releases section and download the latest Windows installer. It will add "Auto Backlight for ThinkPad" to the startup applications to begin automatically with user Log-In. It can be uninstalled easily through "Add or Remove programs" or other similar methods.
If you wish to disable Lenovo on-screen display popups, there is a checkbox "Enable on-screen display" buried in Settings on Windows 10. Access it through Settings-->System-->Display-->Advanced display settings-->Display adapter properties for Display 1-->Screen configurations. See image.
The project is built from Visual Studio 2019 C# WPF project template and Windows Setup project template to create the installer. C# on Microsoft .NET framework was chosen for high-compatibility code without external dependencies, using only the installed framework. Communication to the keyboard is done through Windows IO calls to IbmPmDrv (Lenovo/IBM power management driver), which should be available on these laptops. The camera interface is through third-party Accord.NET image processing libraries which uses Microsoft DirectShow under the hood.
The application hooks to various Windows Win32 Power Management events like Suspend, Resume, Display On/Off, Lid Close/Open to trigger special handling of the backlight state around these events. These events cause update of the keyboard backlight and/or screen backlight. Windows Win32 Raw Input is used to notify the app based on user activity for certain hardware devices (laptop built-in keyboard and mouse). These activity events trigger illumination of the backlight, which is subsequently reset after a timeout. The frequent input events are quickly muted to preserve battery life (cpu usage) when not needed. CPU usage was tested during app development to keep it minimal as a background application.
The Visual Studio solution contains both a C# project (the application itself) and a Windows Setup project (the installer). As long as the core dependency is met on Microsoft .NET Framework, all should build out-of-box on Visual Studio 2019. This project is kept simple and mostly standard/default settings. One trick in use is the redirection of external dll references. These dll files (from included NuGet packages) would normally appear beside the application in the file explorer but most have been embedded inside the executable as part of the build process.
This project is licensed under the Apache-2.0 license. See LICENSE file for full text. See NOTICE file for attributions.