Watch
1
0
Fork
You've already forked souveraine
0

sensord: report edges, not every sample

Light drifts continuously; monitor-sensor emitted ~8 lines/sec and each was
a socket round trip re-asserting the same Changing(false). The keepalive is
what keeps silence meaningful, so only changes need reporting.
This commit is contained in:
Fimeg 2026-07-26 20:03:21 -04:00
commit de3a332513

View file

@ -283,12 +283,25 @@ fn main() {
continue; continue;
} }
let Some(value) = (s.parse)(&line, &mut state) else { continue }; let Some(value) = (s.parse)(&line, &mut state) else { continue };
{ // Only report when the value the machine sees actually
// changes. monitor-sensor emits a line per lux sample and
// ambient light drifts continuously — measured on device at
// ~8 lines/second, every one of them a socket round trip
// carrying `Changing(false)` again. The keepalive already
// guarantees sessiond hears from every source inside
// SOURCE_DOWN_AFTER, so silence between real changes is safe
// and is exactly what §10 arranged for.
let unchanged = {
let mut guard = match last.lock() { let mut guard = match last.lock() {
Ok(g) => g, Ok(g) => g,
Err(p) => p.into_inner(), Err(p) => p.into_inner(),
}; };
let same = guard.get(s.name) == Some(&value);
guard.insert(s.name, value.clone()); guard.insert(s.name, value.clone());
same
};
if unchanged {
break;
} }
// Report both edges. "Far" matters as much as "near": it is // Report both edges. "Far" matters as much as "near": it is
// what re-enables a wake, and it is what proves the sensor is // what re-enables a wake, and it is what proves the sensor is