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.

// battery18/22
year
2026
type
energy monitor for linux
group
systems
status
stable, packaged for fedora

//in plain words

A phone tells you which apps drained the battery. A Linux laptop only shows a percentage. drainscope measures the energy the hardware actually used and works out each app's share, including what it burned while you were not looking at it, then shows it in a tile in the top bar, a desktop app and the terminal. Everything stays on your machine, and nothing runs as root.

for Linux laptop users who want the per-app battery view phones have had for years

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. Without RAPL, battery energy is shared by CPU time above a learned idle floor, and model v4 keeps attributing when RAPL drops out partway through a window. 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 extension is also listed on extensions.gnome.org, and still needs the daemon from the packages.

  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
0.6 pt
in-use share error
against focused time, two equal loads; the criterion was five points
9
releases in 10 days
v0.1.0 on 5 oct to v1.0.0 on 14 oct 2026, model v1 to v4

decisions

//04decisions

  1. 01

    chose proportional sharing above a learned idle floor

    over a machine-learned power model

    Every share is derived from counters the kernel exposes and the shares always sum to the measured energy, which is property tested. The known cost is that light, bursty work is undercharged, and the model document says by how much.

  2. 02

    chose recording the battery shortfall

    over a conversion factor between RAPL and the battery

    Measured, the battery drew 0.77 to 0.90 times what the package counters said, and the ratio moved. Display and devices are reported as battery minus package rather than scaled into the apps.

  3. 03

    chose a separate optional eBPF probe

    over eBPF inside the daemon

    Wakeups and network bytes need three capabilities. Keeping them in their own service with its own user and an empty network namespace means the daemon and the sampler keep one or none, and the probe can be left uninstalled.

  4. 04

    chose reporting the focused app id only

    over window titles

    The in-use and background split needs to know which app has focus, not what you are reading. The extension sends the app id, the daemon accepts it only from the Shell's own process, and titles never leave the compositor.

  5. 05

    chose coarsened, rate-limited counter readings

    over raw RAPL to any caller

    Fine-grained energy counters are a known side channel for reading secrets. polkit limits reads to the active local session and the values are rounded and throttled, which is enough for attribution and not enough for an attack.

try it

//05try it

  1. //install from copr

    sudo dnf copr enable khaledsaeed18/drainscope && sudo dnf install drainscope drainscope-sampler drainscope-probe drainscope-app gnome-shell-extension-drainscope

    fedora 44, 45 or rawhide; gnome 50 or 51 for the tile

  2. //start it and check what your hardware supports

    systemctl --user enable --now drainscope.service && drainscope doctor

    log out and in once for the extension

  3. //see where the battery went since unplugging

    drainscope summary

highlights

//06highlights

  • 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

on githubdrainscope

license
GPL-3.0
language
Rust
latest release
v1.0.1 nov 20, 2026
last push
nov 20, 2026

printings

//07printings

  1. v0.1.0

    Daemon, sampler, CLI, the GNOME extension and the app, with source, SRPM and Fedora 44 RPMs. COPR went live the next day.

  2. v0.1.3 and v0.1.4

    Model v3 with network interrupt threads, CSV and JSON export, the slower idle tick that cut self-cost from about 0.9% to 0.28%, then the in-use and background split per app.

  3. v0.1.6 and v0.1.7

    Model v4, stable lists, the once-a-minute 7-day view, and the failure checklist run end to end: measuring without writable history, clearer polkit messages.

  4. v1.0.0

    The 0.1.7 code declared stable after the 48-hour soak, with the performance, architecture and installation documents. Next: the extension listing review, model v5 for wake cost, and AMD and Intel xe GPU parts.

  5. v1.0.1

    A security update: SQLite 3.54.1 in the history database, and tokio and rustix updated for two RustSec advisories. D-Bus moves to zbus 6 with the same interfaces, and nothing changes in what drainscope measures or shows. The extension listing on extensions.gnome.org was approved two days earlier.

questions

//08questions

Does any of it run as root?
No. The daemon is a user service. The sampler runs as its own user with one capability to read counters, and the optional probe with three for eBPF, both in systemd sandboxes with SELinux modules enforcing.
Which hardware does it support?
Intel laptops with RAPL and i915 graphics are developed and validated. AMD Zen is expected to work from fixtures but untested on real hardware. Intel xe works without per-app GPU energy. Machines without RAPL, including virtual machines, fall back to battery readings split by CPU time. The doctor command says which applies.
Is it private?
No component opens a network socket. History lives in a SQLite file only your user can read, focus is reported by app id and never by window title, and counter readings are limited to the active local session, rate-limited and coarsened.
What happens when a part fails?
The daemon keeps measuring in memory when history is not writable, degrades the available readings without the sampler or probe, recovers when they return without a restart, and exits cleanly rather than touch a database from a newer version. Nine failure cases were run and documented.
How accurate is the per-app split?
The total is measured. The split is an estimate from CPU, GPU and network activity, and the model document states where it is weak: light bursty work is undercharged, and about half a percent of energy lands in processes that exited before the tick.

related sheets

//09related sheets

//10contact

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