System-tray application that automatically restores ThinkPad keyboard backlight after lid-close, power, and display events.
- C# on .NET Framework 4.8.1 (built into Windows 10/11)
- WPF for the Info and About dialog windows
- WinForms for
NotifyIcon+ContextMenuStrip - WMI (
System.Management) for event monitoring
- Entry point is
Program.cs([STAThread]); callsnew App().Run(). AppinheritsSystem.Windows.Application,ShutdownMode = OnExplicitShutdown.- On startup the saved backlight level is restored immediately.
- Event restore pipeline is
EventMonitor.cs→App.RestoreBacklight()→BacklightController.cs. - Backlight restore only runs on the physical console session (skipped in RDP).
- Backlight is controlled exclusively via the IBMPmDrv kernel driver (
\\.\IBMPmDrv) using IOCTLs CTL_CODE(34, 2464/2465, 0, 0) with KBAG/KBAS fallback. - Fn+Space level changes are detected via
HKLM\...\IBMPMSVC\Parameters\Notificationand persisted automatically. - Tray menu and dialogs follow the OS dark / light theme.
Download the MSI installer from the latest
GitHub Release and run it — no admin required.
The installer places files under %LOCALAPPDATA%\ThinkPad-Backlight-Tray and
registers auto-start via HKCU\...\Run. Auto-start can also be toggled from
the tray menu ("Run at Startup").
# Silent install
msiexec /i ThinkPad-Backlight-Tray-Setup-vX.Y.Z.msi /quiet
# Install with progress bar
msiexec /i ThinkPad-Backlight-Tray-Setup-vX.Y.Z.msi /passiveA portable zip is also provided for manual use.
- Windows 10 1809+ or Windows 11 (x64)
- ThinkPad with keyboard backlight support and the Lenovo power management driver (
IBMPmDrv)
# Application
dotnet build -c Release
# MSI installer (requires the WiX v6 dotnet tool)
dotnet tool install --global wix
dotnet build installer\ThinkPad-Backlight-Tray.Installer.wixproj `
-p:Version=1.0.1 `
-p:PublishDir=$(Resolve-Path .\publish).\bin\Release\net481\ThinkPad-Backlight-Tray.exe--off / --dim / --full Set backlight level and exit
--restore Restore backlight level and exit
--restore-to <last|dim|full>
Set which level to restore to
--startup-on / --startup-off Toggle run-at-startup
--info Print driver diagnostics and exit
--debug Launch tray with live debug logging to a console window
--help Show usage
Registry root: HKEY_CURRENT_USER\Software\ThinkPad-Backlight-Tray
BacklightLevel(DWORD):0Off,1Dim,2FullAutoRestore(DWORD):1enabled (default),0disabledRestoreLevel(DWORD):0Last (default),1Dim,2Full
This project uses Semantic Versioning.
- The single source of truth for the version number is the
<Version>property inThinkPad-Backlight-Tray.csproj. - All notable changes are recorded in
CHANGELOG.mdfollowing the Keep a Changelog format.
Release checklist:
- Update
<Version>inThinkPad-Backlight-Tray.csproj. - Add a new section to
CHANGELOG.mdwith the version and date. - Commit:
git commit -am "Release vX.Y.Z". - Tag:
git tag vX.Y.Z. - Push:
git push --follow-tags.
Pushing a v* tag triggers the Release GitHub Action
(.github/workflows/release.yml), which builds the project and publishes a
portable zip and per-user installer to GitHub Releases.
App.cs— WPF Application subclass: lifecycle, NotifyIcon, tray menu, Info dialog, About dialog, restore callbacksBacklightController.cs— IBMPmDrv wrapper + retriesPmDriverBacklightController.cs— IBMPmDrv IOCTL set/get (MLCG/MLCS + KBAG/KBAS fallback)EventMonitor.cs— WMI watchers + display polling + Fn+Space watcherSessionHelper.cs— physical console session detectionSettingsManager.cs— registry persistence (backlight level, auto-restore, run-at-startup)Program.cs— entry point ([STAThread]) + CLI switch handlerinstaller/setup.wxs— WiX v6 MSI installer sourceinstaller/ThinkPad-Backlight-Tray.Installer.wixproj— WiX MSBuild project (per-user, no admin)
MIT