mirror of
https://github.com/polybar/polybar.git
synced 2026-02-17 13:45:58 +00:00
refactor(modules): Handle events using signal_receiver
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user