Unify paths...

This commit is contained in:
2026-01-25 17:47:32 -05:00
parent d34a149716
commit 9af82632b1

View File

@ -9,6 +9,7 @@
#include <algorithm>
#include <sstream>
#include <string>
#include <filesystem>
namespace C
{
@ -21,7 +22,10 @@ namespace C
const double updateTimeout= 0.1;
}
const std::string conservePath= "/sys/devices/pci0000:00/0000:00:1f.0/PNP0C09:00/VPC2004:00/conservation_mode";
const std::filesystem::path conservePath= "/sys/devices/pci0000:00/0000:00:1f.0/PNP0C09:00/VPC2004:00/conservation_mode";
const std::filesystem::path powerPath= "/sys/class/power_supply/ADP0";
const std::filesystem::path batteryPath= "/sys/class/power_supply/BAT0";
const std::filesystem::path backlightPath= "/sys/class/backlight/intel_backlight";
const std::map< int, Fl_Color > levelColors=
{
@ -50,7 +54,7 @@ scheduledUpdate( void * )
Fl::repeat_timeout( C::updateTimeout, scheduledUpdate, nullptr );
if( C::debugUpdateCalled ) std::cerr << "Update!" << std::endl;
std::ifstream batt{ "/sys/class/power_supply/BAT0/capacity" };
std::ifstream batt{ batteryPath / "capacity" };
batt >> battLevelString;
std::istringstream iss{ battLevelString };
int battlevel= 2;
@ -72,20 +76,20 @@ scheduledUpdate( void * )
}
if( C::debugUpdate ) std::cerr << "Conservation state read as: " << cons << std::endl;
std::ifstream acCheck{ "/sys/class/power_supply/ADP0/online" };
std::ifstream acCheck{ powerPath / "online" };
int ac= -1;
acCheck >> ac;
acButton->value( ac );
if( C::debugUpdate ) std::cerr << "AC state read as: " << ac << std::endl;
std::ifstream i_max{ "/sys/class/backlight/intel_backlight/max_brightness" };
std::ifstream i_max{ backlightPath / "max_brightness" };
int max;
i_max >> max;
std::ifstream inf{ "/sys/class/backlight/intel_backlight/brightness" };
std::ifstream inf{ backlightPath / "brightness" };
int in;
inf >> in;
@ -178,7 +182,7 @@ namespace
void
changeBrightness( int pct )
{
std::ifstream i_max{ "/sys/class/backlight/intel_backlight/max_brightness" };
std::ifstream i_max{ backlightPath / "max_brightness" };
int max;
i_max >> max;
@ -186,7 +190,7 @@ namespace
int adj= max * pct / 100;
std::cerr << "Adjustment computed: " << adj << std::endl;
std::ofstream out{ "/sys/class/backlight/intel_backlight/brightness" };
std::ofstream out{ backlightPath / "brightness" };
out << adj;
}