# maniacx/battery-health-charging architecture

> Architecture diagram of the GitHub repository maniacx/battery-health-charging, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/maniacx/battery-health-charging
- Repository: https://github.com/maniacx/battery-health-charging

## Overview

Battery Health Charging is a GNOME Shell extension for detecting supported laptop batteries and configuring charge limits and modes. Its runtime selects a device-specific backend, applies thresholds through privileged commands, and presents status and controls in Quick Settings. A separate preferences workflow exposes general settings and device-dependent threshold and vendor options. The graph preserves the documented device-backend and settings branches; unsampled files are grouped where their exact behavior is not shown.

Main entry points: [`prefs.js`](https://github.com/maniacx/battery-health-charging/blob/GNOME45/prefs.js) (Preferences entry), [`lib/driver.js`](https://github.com/maniacx/battery-health-charging/blob/GNOME45/lib/driver.js) (Device driver), [`lib/deviceList.js`](https://github.com/maniacx/battery-health-charging/blob/GNOME45/lib/deviceList.js) (Device registry), [`lib/helper.js`](https://github.com/maniacx/battery-health-charging/blob/GNOME45/lib/helper.js) (System helpers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Shell runtime"]
  node_extension["Extension lifecycle<br/>[extension.js]"]
  node_driver["Device driver<br/>[driver.js]"]
  node_helper["System helpers<br/>[helper.js]"]
  node_notifier["Notifications<br/>[notifier.js]"]
  node_panel["Quick Settings<br/>[thresholdPanel.js]"]
  node_power["Power icon<br/>[powerIcon.js]"]
  node_polkit["Policy indicator"]
end

subgraph group_devices["Device support"]
  node_registry["Device registry<br/>[deviceList.js]"]
  node_thinkpad["ThinkPad backend<br/>[Thinkpad.js]"]
  node_legacy["Legacy ThinkPad backend<br/>[ThinkpadLegacy.js]"]
  node_dell["Dell backend<br/>[Dell.js]"]
  node_other["Other vendor backends"]
end

subgraph group_prefs["Preferences"]
  node_prefs_entry["Preferences entry<br/>[prefs.js]"]
  node_general["General settings<br/>[general.js]"]
  node_primary["Primary thresholds"]
  node_secondary["Secondary thresholds"]
  node_vendor_prefs["Vendor settings"]
  node_about["About page<br/>[about.js]"]
end

node_user(("Laptop user"))
node_gnome(("GNOME Shell"))

node_gnome -->|"loads"| node_extension
node_extension -->|"starts"| node_driver
node_extension -->|"creates"| node_power
node_driver -->|"selects device"| node_registry
node_driver -->|"uses"| node_helper
node_driver -->|"notifies"| node_notifier
node_driver -->|"creates controls"| node_panel
node_driver -->|"uses"| node_polkit
node_registry -->|"registers"| node_thinkpad
node_registry -->|"registers"| node_legacy
node_registry -->|"registers"| node_dell
node_registry -->|"registers"| node_other
node_thinkpad -->|"uses"| node_helper
node_legacy -->|"uses"| node_helper
node_dell -->|"uses"| node_helper
node_other -->|"uses"| node_helper
node_user -->|"opens settings"| node_prefs_entry
node_prefs_entry -->|"resolves device"| node_registry
node_prefs_entry -->|"adds page"| node_general
node_prefs_entry -->|"adds page"| node_primary
node_prefs_entry -->|"adds page"| node_secondary
node_prefs_entry -->|"adds vendor pages"| node_vendor_prefs
node_prefs_entry -->|"adds page"| node_about
node_general -->|"uses"| node_helper

click node_extension "https://github.com/maniacx/battery-health-charging/blob/GNOME45/extension.js"
click node_driver "https://github.com/maniacx/battery-health-charging/blob/GNOME45/lib/driver.js"
click node_helper "https://github.com/maniacx/battery-health-charging/blob/GNOME45/lib/helper.js"
click node_notifier "https://github.com/maniacx/battery-health-charging/blob/GNOME45/lib/notifier.js"
click node_panel "https://github.com/maniacx/battery-health-charging/blob/GNOME45/lib/thresholdPanel.js"
click node_power "https://github.com/maniacx/battery-health-charging/blob/GNOME45/lib/powerIcon.js"
click node_polkit "https://github.com/maniacx/battery-health-charging/blob/GNOME45/lib/polkitErrorIndicator.js"
click node_registry "https://github.com/maniacx/battery-health-charging/blob/GNOME45/lib/deviceList.js"
click node_thinkpad "https://github.com/maniacx/battery-health-charging/blob/GNOME45/devices/Thinkpad.js"
click node_legacy "https://github.com/maniacx/battery-health-charging/blob/GNOME45/devices/ThinkpadLegacy.js"
click node_dell "https://github.com/maniacx/battery-health-charging/blob/GNOME45/devices/Dell.js"
click node_other "https://github.com/maniacx/battery-health-charging/tree/GNOME45/devices"
click node_prefs_entry "https://github.com/maniacx/battery-health-charging/blob/GNOME45/prefs.js"
click node_general "https://github.com/maniacx/battery-health-charging/blob/GNOME45/preferences/general.js"
click node_primary "https://github.com/maniacx/battery-health-charging/blob/GNOME45/preferences/thresholdPrimary.js"
click node_secondary "https://github.com/maniacx/battery-health-charging/blob/GNOME45/preferences/thresholdSecondary.js"
click node_vendor_prefs "https://github.com/maniacx/battery-health-charging/tree/GNOME45/preferences"
click node_about "https://github.com/maniacx/battery-health-charging/blob/GNOME45/preferences/about.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_extension,node_driver,node_helper,node_notifier,node_panel,node_power,node_polkit,node_user toneBlue
class node_registry,node_thinkpad,node_legacy,node_dell,node_other toneAmber
class node_prefs_entry,node_general,node_primary,node_secondary,node_vendor_prefs,node_about toneMint
class node_gnome toneIndigo
```

## Components

### Shell runtime

- [Extension lifecycle](https://github.com/maniacx/battery-health-charging/blob/GNOME45/extension.js): `extension.js`
- [Device driver](https://github.com/maniacx/battery-health-charging/blob/GNOME45/lib/driver.js): `lib/driver.js`
- [System helpers](https://github.com/maniacx/battery-health-charging/blob/GNOME45/lib/helper.js): `lib/helper.js`
- [Notifications](https://github.com/maniacx/battery-health-charging/blob/GNOME45/lib/notifier.js): `lib/notifier.js`
- [Quick Settings](https://github.com/maniacx/battery-health-charging/blob/GNOME45/lib/thresholdPanel.js): `lib/thresholdPanel.js`
- [Power icon](https://github.com/maniacx/battery-health-charging/blob/GNOME45/lib/powerIcon.js): `lib/powerIcon.js`
- [Policy indicator](https://github.com/maniacx/battery-health-charging/blob/GNOME45/lib/polkitErrorIndicator.js): `lib/polkitErrorIndicator.js`

### Device support

- [Device registry](https://github.com/maniacx/battery-health-charging/blob/GNOME45/lib/deviceList.js): `lib/deviceList.js`
- [ThinkPad backend](https://github.com/maniacx/battery-health-charging/blob/GNOME45/devices/Thinkpad.js): `devices/Thinkpad.js`
- [Legacy ThinkPad backend](https://github.com/maniacx/battery-health-charging/blob/GNOME45/devices/ThinkpadLegacy.js): `devices/ThinkpadLegacy.js`
- [Dell backend](https://github.com/maniacx/battery-health-charging/blob/GNOME45/devices/Dell.js): `devices/Dell.js`
- [Other vendor backends](https://github.com/maniacx/battery-health-charging/tree/GNOME45/devices): `devices`

### Preferences

- [Preferences entry](https://github.com/maniacx/battery-health-charging/blob/GNOME45/prefs.js): `prefs.js`
- [General settings](https://github.com/maniacx/battery-health-charging/blob/GNOME45/preferences/general.js): `preferences/general.js`
- [Primary thresholds](https://github.com/maniacx/battery-health-charging/blob/GNOME45/preferences/thresholdPrimary.js): `preferences/thresholdPrimary.js`
- [Secondary thresholds](https://github.com/maniacx/battery-health-charging/blob/GNOME45/preferences/thresholdSecondary.js): `preferences/thresholdSecondary.js`
- [Vendor settings](https://github.com/maniacx/battery-health-charging/tree/GNOME45/preferences): `preferences`
- [About page](https://github.com/maniacx/battery-health-charging/blob/GNOME45/preferences/about.js): `preferences/about.js`

### Other components

- **Laptop user**
- **GNOME Shell**

## Connections

- GNOME Shell → Extension lifecycle: loads (evidence: `extension.js`)
- Extension lifecycle → Device driver: starts (evidence: `extension.js`)
- Extension lifecycle → Power icon: creates (evidence: `extension.js`)
- Device driver → Device registry: selects device (evidence: `lib/driver.js`)
- Device driver → System helpers: uses (evidence: `lib/driver.js`)
- Device driver → Notifications: notifies (evidence: `lib/driver.js`)
- Device driver → Quick Settings: creates controls (evidence: `lib/driver.js`)
- Device driver → Policy indicator: uses (evidence: `lib/driver.js`)
- Device registry → ThinkPad backend: registers (evidence: `lib/deviceList.js`)
- Device registry → Legacy ThinkPad backend: registers (evidence: `lib/deviceList.js`)
- Device registry → Dell backend: registers (evidence: `lib/deviceList.js`)
- Device registry → Other vendor backends: registers (evidence: `lib/deviceList.js`)
- ThinkPad backend → System helpers: uses (evidence: `devices/Thinkpad.js`)
- Legacy ThinkPad backend → System helpers: uses (evidence: `devices/ThinkpadLegacy.js`)
- Dell backend → System helpers: uses (evidence: `devices/Dell.js`)
- Other vendor backends → System helpers: uses (evidence: `devices/Asahi.js`)
- Laptop user → Preferences entry: opens settings (evidence: `prefs.js`)
- Preferences entry → Device registry: resolves device (evidence: `prefs.js`)
- Preferences entry → General settings: adds page (evidence: `prefs.js`)
- Preferences entry → Primary thresholds: adds page (evidence: `prefs.js`)
- Preferences entry → Secondary thresholds: adds page (evidence: `prefs.js`)
- Preferences entry → Vendor settings: adds vendor pages (evidence: `prefs.js`)
- Preferences entry → About page: adds page (evidence: `prefs.js`)
- General settings → System helpers: uses (evidence: `preferences/general.js`)
