battery-d 0.0.1

Simple way to get battery info

To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

battery-d Page on DUB License CircleCI

battery-d - simple library for reading battery info on linux laptops. Provides access to battery status (discharging, charging or full), battery level (0-100%), time remaining and time until full. Also provides access to raw data (which can differ on different laptops).

Basic usage

dub run battery-d

As library

battery-d can be used as library. Just add it to dependencies in dub.json. Example usage:

import std.stdio;
import battery.d;

void main() {
	auto b = new Battery();
	writeln("Level: ", b.level);
	writeln("Status: ", b.status);

Advanced usage

battery-d have been developed as rewrite of old perl script, which parses output of acpi command. By default battery-d -pc outputs coloured battery level:

  • <= 20% - red
  • <= 50% - yellow
  • <= 100% - green

Output can be customized by editing code or cli arguments:

battery-d -pc --threshold=30=["%F{orange}","%%%f"]

This command adds new threshold, which prepends battery level with %F{orange} and appends %%%f. Output will look like this:


In zsh it produces orange-coloured 29%.

  • Azbuka
0.0.2 2017-Mar-04
0.0.1 2017-Feb-19
0.0.0 2017-Feb-19
~master 2017-Mar-04
~docs 2017-Feb-26
Show all 5 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 22 downloads total

Short URL: