refactor(modules): Handle events using signal_receiver

This commit is contained in:
Michael Carlberg
2016-12-21 08:38:44 +01:00
parent c01f111e34
commit 7979f5b3d4
26 changed files with 176 additions and 161 deletions

View File

@ -14,6 +14,17 @@ namespace modules {
template class module<backlight_module>;
template class inotify_module<backlight_module>;
void backlight_module::brightness_handle::filepath(const string& path) {
if (!file_util::exists(path)) {
throw module_error("The file '" + path + "' does not exist");
}
m_path = path;
}
float backlight_module::brightness_handle::read() const {
return std::strtof(file_util::get_contents(m_path).c_str(), nullptr);
}
backlight_module::backlight_module(const bar_settings& bar, string name_)
: inotify_module<backlight_module>(bar, move(name_)) {
auto card = m_conf.get<string>(name(), "card");
@ -39,17 +50,6 @@ namespace modules {
watch(string_util::replace(PATH_BACKLIGHT_VAL, "%card%", card));
}
void brightness_handle::filepath(const string& path) {
if (!file_util::exists(path)) {
throw module_error("The file '" + path + "' does not exist");
}
m_path = path;
}
float brightness_handle::read() const {
return std::strtof(file_util::get_contents(m_path).c_str(), nullptr);
}
void backlight_module::idle() {
sleep(75ms);
}