skip to content

// energy monitor for linux

drainscope

See where your Linux laptop's battery goes, by app, terminal command and service.

drainscope measures energy from hardware counters and the battery, then estimates each app's share, including time in use and in the background. A GNOME Quick Settings extension, desktop app and CLI show local history, sleep loss, battery health, wakeups and network activity. Version 1.0.0 is the first stable release, backed by failure testing and a 48-hour soak test on the development laptop.

// battery17/21
year
2026
type
energy monitor for linux
group
systems
status
v1.0.0 stable, packaged for fedora

the problem

//01the problem

A battery percentage says how much charge is left, but not which app spent it or whether it was working in the background. Linux exposes energy and activity counters across the kernel and desktop, with different permissions and gaps in hardware support. I wanted to turn those readings into a useful account of where the battery went, without running a monitor as root.

how it works

//02how it works

  1. 01

    Measure the total, explain each share

    RAPL counters and battery readings provide the measured energy. A user service combines cgroup v2 CPU time and GPU time from DRM fdinfo to estimate each consumer's share above a learned idle floor. Model v4 also shares energy by CPU time when RAPL is unavailable. Network softirq and threaded interrupt work follow the apps' measured traffic, while Idle and Display & devices remain visible parts of the total.

  2. 02

    In use or in the background

    The GNOME extension reports the focused app's ID, never its window title. The daemon uses focused time to split each app's energy into in use, background and unknown, shown in app details, CLI reports and exports. Without focus data, the split stays unknown; terminal tabs and services are not classified. In a controlled test with two equal loads, in-use energy shares matched focused-time shares within 0.6 percentage points.

  3. 03

    Three ways into the same history

    GNOME 50 and 51 get a Quick Settings tile showing the top consumers since unplugging. The GTK and libadwaita app adds a stacked timeline, per-consumer detail and views for the last hour, 24 hours or 7 days. The CLI adds live power and reports filtered by period, consumer kind or power source. Lists stay stable as readings change, and the app follows daemon stops and restarts with clear status messages.

  4. 04

    Activity, sleep and battery wear

    The optional eBPF probe counts per-app CPU wakeups and network bytes, excluding loopback traffic. Sleep history records battery loss and reports wake reasons only when reliable. Daily battery-health records track capacity against design and charge cycles. Attribution pauses across suspend, and the since-unplugged session resets after charging while the machine was off.

  5. 05

    Least privilege and local history

    No component runs as root or opens a network socket. The sampler and optional probe run as dedicated users with one and three Linux capabilities respectively, confined by systemd sandboxes and SELinux where enabled. polkit restricts counter access to the active local session; readings are rate-limited and coarsened. Energy and focus history stay in the user's local SQLite database.

  6. 06

    Keep measuring when parts fail

    The daemon can start without writable history, using in-memory storage, and keeps measuring when the disk fills. Missing sampler or probe services degrade the available readings instead of stopping collection. It recovers from an unreadable database, stops safely on a newer schema, and handles counter resets after service restarts. A documented failure checklist covers denied permissions, missing services, full disks and desktop restarts; drainscope doctor explains what needs attention.

  7. 07

    A stable release with measured overhead

    Sampling slows to every 15 seconds when no view is watching and returns to 5 seconds while a view is open. Batched readings, faster history queries and a once-a-minute refresh for the 7-day view keep the cost down. Across a 48-hour soak of the code shipped as 1.0, the daemon averaged 0.179% of one CPU and peaked at 14.1 MB on the development laptop, with no service warnings, extension errors or SELinux denials. These are daemon figures, not the cost of all components combined.

  8. 08

    Reports you can take with you

    Summary, report, sleep, health, wakeups and network views export every row as CSV or JSON in joules, watts and Unix seconds. Reports include foreground, background and unknown energy plus focused time; JSON includes the period, measured coverage and model version. Unknown readings stay distinct from zero, including history recorded before focus tracking existed.

  9. 09

    Packaged, documented and upgradeable

    The first stable release ships signed COPR packages for Fedora 44, 45 and rawhide, with installation checked on Fedora 44 and 45. Updates arrive through dnf and restart the daemon. Release downloads also include Fedora 44 RPMs and the extension zip. Architecture, installation, troubleshooting and contribution guides accompany the release; the extensions.gnome.org listing is still awaiting review.

  10. 10

    Make the limits visible

    Validation uses recorded trace replays and real measurements on an Intel i7-8550U laptop with i915 graphics. AMD Zen support is expected from fixtures but has not been tested on real hardware; its integrated-GPU energy is split by CPU time, and Intel xe GPU energy is not yet split per app. Light, bursty work remains undercharged by proportional sharing. The published model and validation explain these limits rather than presenting per-app estimates as direct measurements.

measured

//03measured

0.18%
average daemon cpu
of one cpu, 48-hour soak on the development laptop
14.1 MB
peak daemon memory
same soak test; sampler and probe measured separately
48 h
soak test
v0.1.7, the code shipped as 1.0; no service warnings
0
components running as root
one capability on the sampler, three on the optional probe

highlights

//04highlights

  • First stable release, v1.0.0, published on October 14, 2026
  • Foreground and background energy in app details, CLI reports and exports, with unknown time kept explicit
  • Model v4 supports battery-only attribution alongside CPU, GPU and network activity accounting
  • Per-app wakeups and traffic, suspend loss and daily battery-health history
  • 48-hour soak test with 0.18% average daemon CPU and 14.1 MB peak daemon memory on the development laptop
  • Failure recovery checked across missing services, permission denials, full disks and restarts
  • Signed Fedora 44, 45 and rawhide packages; GNOME 50 and 51 support
  • Local history, no network access and no component running as root

built with

  • Rust
  • eBPF
  • systemd
  • D-Bus
  • SQLite
  • SELinux
  • GNOME Shell
  • GTK
  • libadwaita
  • TypeScript

//05contact

Say hello. I read everything.

Email is the fastest way to reach me. For anything that needs a conversation, book a call.

to

name
Khaled Saeed
country
Lebanon