fix(battery): Check file existance
This commit is contained in:
parent
9321fb0db9
commit
f1e7991279
@ -53,8 +53,16 @@ BatteryModule::BatteryModule(const std::string& name_) : InotifyModule(name_)
|
|||||||
this->label_full = drawtypes::get_optional_config_label(
|
this->label_full = drawtypes::get_optional_config_label(
|
||||||
name(), get_tag_name(TAG_LABEL_FULL), "%percentage%");
|
name(), get_tag_name(TAG_LABEL_FULL), "%percentage%");
|
||||||
|
|
||||||
this->watch(string::replace(PATH_BATTERY_CAPACITY, "%battery%", this->battery), InotifyEvent::ACCESSED);
|
const auto capacity_path = string::replace(PATH_BATTERY_CAPACITY, "%battery%", this->battery);
|
||||||
this->watch(string::replace(PATH_ADAPTER_STATUS, "%adapter%", this->adapter), InotifyEvent::ACCESSED);
|
const auto adapter_path = string::replace(PATH_ADAPTER_STATUS, "%adapter%", this->adapter);
|
||||||
|
|
||||||
|
if (!io::file::exists(capacity_path))
|
||||||
|
throw ModuleError("[BatteryModule] The file \""+ capacity_path +"\" does not exist");
|
||||||
|
if (!io::file::exists(adapter_path))
|
||||||
|
throw ModuleError("[BatteryModule] The file \""+ adapter_path +"\" does not exist");
|
||||||
|
|
||||||
|
this->watch(capacity_path, InotifyEvent::ACCESSED);
|
||||||
|
this->watch(adapter_path, InotifyEvent::ACCESSED);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BatteryModule::start()
|
void BatteryModule::start()
|
||||||
|
Loading…
Reference in New Issue
Block a user