From 4cb0d240b11770577fafba03a5daac62834a7c57d056149bd18cc9682c61082c Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Mon, 26 Jan 2026 02:17:05 -0500 Subject: [PATCH] Allow brightness to go to absolute minimum This assumes that 1 keeps the backlight on and 0 turns the backlight off. --- power_console_main.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/power_console_main.cc b/power_console_main.cc index c8c3fef..ad5b995 100644 --- a/power_console_main.cc +++ b/power_console_main.cc @@ -120,7 +120,7 @@ main( const int argcnt, char **argvec ) level->value( 0 ); level->label( battLevelString.c_str() ); - brightness->maximum( 1 ); + brightness->maximum( 0 ); brightness->minimum( 100 ); brightness->step( -1 ); @@ -187,7 +187,8 @@ namespace int max; i_max >> max; - int adj= max * pct / 100; + // Clamp to never hit 0 backlight or pass max. + int adj= std::clamp( max * pct / 100, 1, max ); std::cerr << "Adjustment computed: " << adj << std::endl; std::ofstream out{ backlightPath / "brightness" }; @@ -212,5 +213,5 @@ adjustBrightness( MouseWheelSlider *, void * ) { const int amount= brightness->value(); std::cerr << "Adjusting brightness by " << amount << std::endl; - changeBrightness( std::clamp( amount, 1, 100 ) ); + changeBrightness( amount ); }