Show HN: A (marginally) useful x86-64 ELF executable in 301 bytes

April 9, 2026
Detailed view of grouped cylindrical batteries showcasing industrial energy concepts.
Photo by Hilary Halliwell on Pexels

What it does

Tiny but tidy: a single-file ELF program that prints your laptop battery status. Run btry and you get something like "30.6 Wh / 31.1 Wh (98%)" or, on machines that expose charge_ rather than energy_ files, "2.2 Ah / 2.8 Ah (78%)". The GitHub repo actually supplies a 298‑byte executable (the post title says 301 bytes), and you can install it by decoding a base64/xz blob the author provides. Who needs a GUI for that? Sometimes small things are satisfying.

How it works

btry simply reads files under /sys/class/power_supply/BAT0 and prints the current and full values plus a percentage. If energy_now/energy_full are present it reports watt‑hours; if charge_now/charge_full are present it reports ampere‑hours. It has been reported that on a ThinkPad X220 the kernel exposes charge_ files when plugged in at wake and energy_ when not plugged in — neat, if a bit quirky. Build instructions are minimal: the prebuilt binary can be written out with the base64/xz snippet, or you can run make on x86‑64 Linux.

Limitations and quirks

This is deliberately single‑purpose and tiny. It only targets x86‑64 Linux and assumes /sys/class/power_supply/BAT0 exists; portability is not a concern here. If neither an energy_full nor a charge_full file exists the program reportedly enters an infinite loop, and extra batteries (like an internal + slice setup) are ignored. In short: great for one‑battery laptops, not a drop‑in replacement for a power manager.

Takeaway

A charming bit of Unix minimalism with a practical payoff — compact, fast, and oddly satisfying. It’s the kind of hack that makes you smile: no dependencies, no UI, just a very small tool that does one thing well. If you enjoy tiny, clever utilities or need a quick battery check in a constrained environment, btry is worth a look.

Sources: github.com/meribold, Hacker News