elkowar/eww · error
Eww doesn't support your OS for getting the battery capacity
Error message
Eww doesn't support your OS for getting the battery capacity
What it means
get_battery_capacity has platform-specific implementations for macOS, Linux, NetBSD, FreeBSD and OpenBSD, gated by cfg attributes. On any other OS, this stub is compiled and unconditionally returns this error, since eww has no battery-reading code path for that platform.
Solutions
- Run eww on a supported OS (Linux, macOS, or the listed BSDs)
- Avoid battery widgets/variables on unsupported platforms
- Contribute a get_battery_capacity implementation for your OS behind a new cfg gate
Defensive patterns
Strategy: fallback
Validate before calling
// cfg-gate battery usage in dependent code #[cfg(any(target_os = "linux", target_os = "macos"))] let capacity = system_stats::get_battery_capacity();
Try / catch
match get_battery_capacity() {
Ok(v) => v,
Err(_) => String::from("N/A"), // fallback display
} Prevention
- Only use battery widgets on supported platforms
- Provide a fallback display value in widgets
- Check eww's platform support matrix before porting
When it happens
Trigger: Any widget/config referencing battery capacity (e.g. the EWW_BATTERY variable or a battery stats call) on a target OS that is none of macos/linux/netbsd/freebsd/openbsd — e.g. Windows or a niche BSD.
Common situations: Building/running eww on an unsupported platform such as Windows; cross-compiling for an unusual target and using battery widgets.
Understand the failure class
Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.
Related errors
- Script var ' ' is not polling
- CSS error
- The script for the ` `-variable exited unsuccessfully
- Encountered both an SCSS and CSS file. Only one of these…
- SCSS parsing error
AI-assisted analysis of elkowar/eww@48f5aa8b37 (2026-09-08).
Data as JSON: /api/errors/fc0948212339849b.
Report an issue: GitHub.
Appendix: source
Thrown at crates/eww/src/config/system_stats.rs:254
json.push_str(&format!(
r#""BAT{}": {{ "status": "{}", "capacity": {} }}, "#,
bat.get(1).unwrap().as_str(),
bat.get(2).unwrap().as_str(),
bat.get(3).unwrap().as_str(),
))
}
json.push_str(&format!(r#""total_avg": {}}}"#, re_total.captures(&batteries).unwrap().get(1).unwrap().as_str()));
Ok(json)
}
#[cfg(not(target_os = "macos"))]
#[cfg(not(target_os = "linux"))]
#[cfg(not(target_os = "netbsd"))]
#[cfg(not(target_os = "freebsd"))]
#[cfg(not(target_os = "openbsd"))]
pub fn get_battery_capacity() -> Result<String> {
Err(anyhow::anyhow!("Eww doesn't support your OS for getting the battery capacity"))
}
pub fn net() -> String {
let (ref mut last_refresh, ref mut networks) = &mut *NETWORKS.lock().unwrap();
networks.refresh_list();
let elapsed = last_refresh.next_refresh();
networks
.iter()
.map(|(name, data)| {
let transmitted = data.transmitted() as f64 / elapsed.as_secs_f64();
let received = data.received() as f64 / elapsed.as_secs_f64();
(name, serde_json::json!({ "NET_UP": transmitted, "NET_DOWN": received }))
})
.collect::<serde_json::Value>()
.to_string()
}View on GitHub (pinned to 48f5aa8b37)