diff --git a/README.md b/README.md index 5178783a..83960002 100644 --- a/README.md +++ b/README.md @@ -205,7 +205,8 @@ the resulting output might not be award-winning. ;battery = BAT0 ;adapter = ADP1 - ; Seconds between reading battery capacity + ; Seconds between reading battery capacity. + ; If set to 0, polling will be disabled. ;poll_interval = 3 ~~~ diff --git a/src/modules/battery.cpp b/src/modules/battery.cpp index cf6a3821..96985d8a 100644 --- a/src/modules/battery.cpp +++ b/src/modules/battery.cpp @@ -78,7 +78,7 @@ void BatteryModule::subthread_runner() // TODO(jaagr): Keep track of when the values were last read to determine // if we need to trigger the event manually or not. - if ((++i % poll_seconds) == 0) { + if (poll_seconds > 0 && (++i % poll_seconds) == 0) { // Trigger an inotify event in case the underlying filesystem doesn't log_debug("Poll battery capacity"); io::file::get_contents("/sys/class/power_supply/BAT0/capacity");