added scope filter to dodge bluetooth devices
Browse files
+10 −6 src/bar/blocks/battery.rs
| @@ -27,18 +27,22 @@ fn detect_battery_name() -> Option<String> { | ||
| 27 | 27 | .map(|s| s.trim() == "Battery") |
| 28 | 28 | .unwrap_or(false); |
| 29 | 29 | |
| 30 | - // Some systems omit "present"; treat missing as present. | |
| 31 | 30 | let is_present = fs::read_to_string(&present_path) |
| 32 | 31 | .map(|s| s.trim() == "1") |
| 33 | 32 | .unwrap_or(true); |
| 34 | 33 | |
| 35 | - if is_battery && is_present { | |
| 36 | - if let Some(name) = path.file_name().and_then(|n| n.to_str()) { | |
| 37 | - return Some(name.to_string()); | |
| 38 | - } | |
| 34 | + let is_device_scope = fs::read_to_string(path.join("scope")) | |
| 35 | + .map(|s| s.trim().eq_ignore_ascii_case("device")) | |
| 36 | + .unwrap_or(false); | |
| 37 | + | |
| 38 | + if !is_battery || !is_present || is_device_scope { | |
| 39 | + continue; | |
| 39 | 40 | } |
| 40 | - } | |
| 41 | 41 | |
| 42 | + if let Some(name) = path.file_name().and_then(|n| n.to_str()) { | |
| 43 | + return Some(name.to_string()); | |
| 44 | + } | |
| 45 | + } | |
| 42 | 46 | None |
| 43 | 47 | } |
| 44 | 48 |