Files
chandra/lib/battery/pkg.generated.mbti
T
Claude 88915842c2
CI / test (push) Failing after 18s
Battery panel module: charge, charging state, time left, low-battery warning
- New `battery` panel module (components/battery, logic in lib/battery): a battery icon filled to
  the charge with the percentage and time remaining ("73% 2:05"; time to full while charging).
  The fill turns green when charging or full, amber at 20 % and below, and at 10 % the whole
  button turns red and a "Battery low" popup opens by itself, once per discharge spell. A click
  opens the details (charge, state, time left in words). Without a battery it shows a plug.
- Right-click "Module settings": Show percentage, Show time remaining, and Without a battery
  (Show a plug / Show nothing). Saved per module in state.edn like the clocks' settings.
- New `battery` capability (wit/capabilities.wit: read -> status {percent, charge-state,
  secs-left}). Served by the wasmer stub (host ints 7-9), host-wasm and wasmhost (publish-battery).
- Host side (compositor/shell/battery.mbt): reads /sys/class/power_supply, every battery
  together (energy_* / power_now, or charge_* / current_now; capacity when that is all there
  is; device-scope batteries like mice are skipped). The `system` snapshot the Power tab uses
  now reads the battery through the same code. Time left follows a running average of the
  rate, starting over when the state changes.
- A fresh panel gets the battery module before the clock only on a machine with a battery.
- wasm_stub: MAX_INST 512 -> 2048. The host test binary creates ~70 compositors without
  unloading their modules; at 512 the last tests' panels came up half empty.
- Tests: sysfs reading against a fake power supply (energy and charge units, two packs,
  charging, full, capacity only, no battery), the running average, the module in the panel
  (text, settings, click, the critical warning, the plug), the rendering logic, and a
  host-wasm test of the module.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hky51dmaUqiYW746Gz
2026-11-25 19:53:42 +00:00

80 lines
1.7 KiB
Plaintext

// Generated using `moon info`, DON'T EDIT IT
package "chandra/desktop/lib/battery"
import {
"chandra/desktop/interface/chandra/desktop/theme",
"chandra/desktop/interface/chandra/desktop/types",
"moonbitlang/core/debug",
}
// Values
pub let config : BatteryConfig
pub let critical_percent : Int32
pub fn info() -> (String, String, Int32, Int32, Int32)
pub fn long_time(Int32) -> String
pub let low_percent : Int32
pub fn panel_text(Reading, BatteryConfig) -> String
pub let popup_w : Int32
pub fn render(@types.Size, @theme.Tokens, Reading, BatteryConfig, open? : Bool) -> Array[@types.DrawOp]
pub fn render_popup(@theme.Tokens, Reading, warning? : Bool) -> (Int32, Int32, Array[@types.DrawOp])
pub fn short_time(Int32) -> String
pub let state_charging : Int32
pub let state_discharging : Int32
pub let state_full : Int32
pub let state_none : Int32
pub let state_not_charging : Int32
// Errors
// Types and methods
pub(all) struct BatteryConfig {
mut show_percent : Bool
mut show_time : Bool
mut plug_without_battery : Bool
}
pub fn BatteryConfig::items(Self) -> Array[ConfigEntry]
pub fn BatteryConfig::new() -> Self
pub fn BatteryConfig::set(Self, String, String) -> Bool
#derive(Eq, @debug.Debug)
pub(all) struct ConfigEntry {
key : String
label : String
choices : Array[String]
value : String
}
pub(all) struct LowWarning {
mut fired : Bool
}
pub fn LowWarning::new() -> Self
pub fn LowWarning::update(Self, Reading) -> Bool
#derive(Eq, @debug.Debug)
pub(all) struct Reading {
percent : Int32
state : Int32
secs_left : Int32
}
pub fn Reading::describe(Self) -> String
pub fn Reading::has_battery(Self) -> Bool
pub fn Reading::level(Self) -> Int32
// Type aliases
// Traits