DarkWatt is a browser extension that helps you track the energy comsumption of your screen. It captures a down-scaled screenshot of the current tab (locally of course), computes the average luminance, and adds it with CPU usage statistics by the browser. The resulting data is persisted locally so you can find the sites that are the most battery-friendly.
- Real-time measurement of page luminance (in nits).
- Tracks per-tab CPU time (requires the experimental
chrome.processes
API). - Cross-browser packaging (Chromium & Firefox Nightly).
- Core pixel maths implemented in Rust + WebAssembly.
Important notice: DarkWatt relies on the experimental
chrome.processes
API to monitor CPU usage. Consequently, the extension currently functions only in the Chrome/Chromium Dev channel. You can download a Dev build from https://www.chromium.org/getting-involved/dev-channel/. The API is documented at https://developer.chrome.com/extensions/processes.
Firefox support is planned.w
- latest Chrome or Chromium Dev channel
- If you plan to build from source:
- Rust ≥ 1.70
wasm-pack
- A Bash-compatible shell (for
build.sh
)
Pre-built .zip
packages are attached to every GitHub release.
- Download the archive matching your browser.
- Unzip it somewhere.
- Open
chrome://extensions
(orabout:debugging#/runtime/this-firefox
in Firefox). - Enable "Developer mode" and click "Load unpacked".
- Select the extracted
build/chrome
orbuild/firefox
directory.
# Clone and build the project
$ git clone https://github.com/Luca1905/darkwatt.git
$ cd darkwatt
$ ./build.sh # compiles the WASM crate and creates the extension bundles
The script outputs two ready-to-load directories:
build/chrome/
– load this in Chromium based browsers.build/firefox/
– load this in Firefox Nightly.
- Load the extension as described above.
- Pin the DarkWatt icon to the toolbar.
- Browse as usual; open the popup anytime to see live luminance and accumulated energy data for the current website.
# Run Rust unit tests
$ cargo test -p wasm-mod
# Build only the WASM crate
$ wasm-pack build wasm_mod --dev --target web --out-dir ../extension/js/wasm --out-name wasm_mod
Press the reload button on chrome://extensions
to pick up the changes.
cargo test -p wasm-mod
.
├── extension/ # WebExtension source (JS/HTML/CSS)
│ ├── js/ # background & popup scripts
│ └── assets/ # icons & images
├── wasm_mod/ # Rust crate compiled to WebAssembly
├── build.sh # helper script to build and package the extension
└── media/ # project visuals (logo, screenshots)
DarkWatt is released under the MIT License – see the LICENSE file for full text.
-
git repo
-
set up wasm and extension structure
-
manifest
-
working demo
-
UI scaffhold
-
Luminenance logic
-
tests
-
integrate into js, test using mock data
-
screenshot current tab and draw to smaller canvas
-
implement background service for handling luma data
- create a dxdb in background
- set up message connections to get and save luma data
- implement savings logic
- heuristic function for light mode page into dark mode page
- heuristic function for detecting light e.g. dark mode page
- calculating energy saving from nits saved.
- get display size for energy calculation
-
get CPU usage data
-
store data in dxdb, expose to popup
-
remove annoying errors on installation
- error when on chrome://
- exceeding MAX_CAPTURE_VISIBLE_TAB_CALLS_PER_SECOND
-
get data from background
-
render data in UI
- render most current data
- render total tracked sites
- render savings
-
settings page for custom values
-
analytics page
-
port background to web_sys using wasm
-
firefox integration
-
deploy
-
fix assumptions
- assumed screen max brightness