Working late nights on server migrations and code architectures often means typing in low-light environments. While USB lamps or backlit keyboards are the standard solutions, they consume extra power and add physical clutter. I realized the ultimate light source was already directly in front of me: the monitor.
With a clear vision in mind, I partnered with Google's Gemini AI to rapidly prototype and refine what became LightBar For Keyboard, a lightweight Windows application that creates a reflective light bar at the bottom of the screen to illuminate the keys. Here is how we built it using C# and WPF, tackled the Windows API to manage screen space, and optimized it for modern OLED energy consumption.
The Core Challenge: Desktop Toolbars (AppBar)
The simplest approach to creating a light bar is a borderless, top-most window. However, the immediate UX flaw is that maximized applications (like Chrome or Visual Studio) will either cover the bar or be partially obscured by it.
To solve this, the application needed to behave like the Windows Taskbar. I implemented the native Windows Application Desktop Toolbar (AppBar) API using SHAppBarMessage from shell32.dll.
-
Docked Mode: By registering the application as an AppBar and setting the edge to
ABE_BOTTOM, Windows automatically recalculates the working area of the desktop. - Result: Maximized windows are pushed upward, ensuring the light bar remains entirely visible and never covers any underlying application UI.
-
Floating Mode: For users who need temporary access to the bottom of their screen, I added a state toggle that unregisters the AppBar and enables standard drag-and-drop window movement via
MouseLeftButtonDown.
Enforcing a Single Instance
Because the app directly manipulates the desktop working area, launching multiple overlapping instances would cause UI glitches. To prevent this, I implemented a Mutex in App.xaml.cs to guarantee a single instance constraint.
protected override void OnStartup(StartupEventArgs e)
{
const string appName = "LightBarForKeyboard_UniqueInstance";
bool createdNew;
_mutex = new Mutex(true, appName, out createdNew);
if (!createdNew)
{
Environment.Exit(0);
}
base.OnStartup(e);
// ...
}
The OLED Efficiency Pivot
Initially, the application featured a pure white bar. On standard LCD panels (IPS, TN, VA), the monitor's backlight is entirely on anyway. Displaying a white bar at the bottom of the screen simply twists the liquid crystals to let the existing light pass through. The extra power required is literally 0 W.
However, OLED displays generate light per pixel. A full white bar firing all RGB subpixels across the bottom of a wide monitor consumes approximately 2,0 W. To make the software highly efficient on modern displays, we introduced custom color profiles targeting specific subpixels:
- Pure Green (RGB 0, 255, 0): The human eye is highly sensitive to green light. This provides maximum contrast for reading black keyboard keys while bypassing the blue and red subpixels entirely. Consumption: ~0,5 W (75% savings).
- Pure Red (RGB 255, 0, 0): Excellent for protecting night vision, allowing the user to look away from the screen without eye strain. Consumption: ~0,3 W (85% savings).
- Yellow (RGB 255, 191, 0): A warm, eye-friendly glow achieved by mixing red and green, completely keeping the power-hungry blue subpixel turned off. Consumption: ~0,8 W (60% savings).
Users can seamlessly right-click the bar to switch between these profiles depending on their hardware and lighting preferences.
Deployment and SmartScreen Realities
I packaged the project as a self-contained, single-file executable using .NET 10.0:
dotnet publish -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true
For distribution, I generated an Inno Setup installer. As an independent developer releasing free tools, purchasing an expensive EV Code Signing certificate isn't always practical. Consequently, early adopters will encounter the classic Windows Defender SmartScreen "Windows protected your PC" blue prompt. I added a quick disclaimer in the documentation to guide users to click More info > Run anyway, knowing that as the software gains organic downloads, its Microsoft SmartScreen reputation will naturally build.
Wrapping Up
Building this utilityโand co-piloting the development process with Geminiโwas a highly satisfying exercise in merging legacy Windows APIs with modern hardware considerations. It is a completely free, software-only solution to a hardware problem.
If you want to try it out, check the code, or compile it yourself, the entire project is open-source on GitHub: LightBarForKeyboard Repository.
Top comments (0)