tony / oxwm

added scope filter to dodge bluetooth devices Browse files
tonybtw committed 2026-01-10 parent d65e7f9 commit e120f6b913b1be6bd3d3efed129e11c2d31cacee
Showing 1 changed file with 10 additions and 6 deletions. UnifiedSplit
+10 −6 src/bar/blocks/battery.rs
@@ -27,18 +27,22 @@ fn detect_battery_name() -> Option<String> {
27 .map(|s| s.trim() == "Battery") 27 .map(|s| s.trim() == "Battery")
28 .unwrap_or(false); 28 .unwrap_or(false);
29 29
30 - // Some systems omit "present"; treat missing as present.
31 let is_present = fs::read_to_string(&present_path) 30 let is_present = fs::read_to_string(&present_path)
32 .map(|s| s.trim() == "1") 31 .map(|s| s.trim() == "1")
33 .unwrap_or(true); 32 .unwrap_or(true);
34 33
35 - if is_battery && is_present { 34 + let is_device_scope = fs::read_to_string(path.join("scope"))
36 - if let Some(name) = path.file_name().and_then(|n| n.to_str()) { 35 + .map(|s| s.trim().eq_ignore_ascii_case("device"))
37 - return Some(name.to_string()); 36 + .unwrap_or(false);
38 - } 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 None 46 None
43 } 47 }
44 48