Add option for custom battery path

This commit is contained in:
Dees_Troy
2013-03-01 00:51:39 +00:00
parent c0583f54e4
commit f33b49015a
2 changed files with 15 additions and 0 deletions
+12
View File
@@ -926,7 +926,13 @@ int DataManager::GetMagicValue(const string varName, string& value)
if (curTime.tv_sec > nextSecCheck)
{
char cap_s[4];
#ifdef TW_CUSTOM_BATTERY_PATH
string capacity_file = EXPAND(TW_CUSTOM_BATTERY_PATH);
capacity_file += "/capacity";
FILE * cap = fopen(capacity_file.c_str(),"rt");
#else
FILE * cap = fopen("/sys/class/power_supply/battery/capacity","rt");
#endif
if (cap){
fgets(cap_s, 4, cap);
fclose(cap);
@@ -934,7 +940,13 @@ int DataManager::GetMagicValue(const string varName, string& value)
if (lastVal > 100) lastVal = 101;
if (lastVal < 0) lastVal = 0;
}
#ifdef TW_CUSTOM_BATTERY_PATH
string status_file = EXPAND(TW_CUSTOM_BATTERY_PATH);
status_file += "/status";
cap = fopen(status_file.c_str(),"rt");
#else
cap = fopen("/sys/class/power_supply/battery/status","rt");
#endif
if (cap) {
fgets(cap_s, 2, cap);
fclose(cap);