fix(battery): Make it possible to disable polling

This commit is contained in:
Michael Carlberg 2016-05-31 03:02:08 +02:00
parent 0052ebc7a9
commit de1d5f3f4a
2 changed files with 3 additions and 2 deletions

View File

@ -205,7 +205,8 @@ the resulting output might not be award-winning.
;battery = BAT0 ;battery = BAT0
;adapter = ADP1 ;adapter = ADP1
; Seconds between reading battery capacity ; Seconds between reading battery capacity.
; If set to 0, polling will be disabled.
;poll_interval = 3 ;poll_interval = 3
~~~ ~~~

View File

@ -78,7 +78,7 @@ void BatteryModule::subthread_runner()
// TODO(jaagr): Keep track of when the values were last read to determine // TODO(jaagr): Keep track of when the values were last read to determine
// if we need to trigger the event manually or not. // 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 // Trigger an inotify event in case the underlying filesystem doesn't
log_debug("Poll battery capacity"); log_debug("Poll battery capacity");
io::file::get_contents("/sys/class/power_supply/BAT0/capacity"); io::file::get_contents("/sys/class/power_supply/BAT0/capacity");