0.2.2 • Published 10 years ago

node-battery v0.2.2

Weekly downloads
9
License
MIT
Repository
github
Last release
10 years ago

Node.js Battery Module

This module provides information on linux and osx about the power sources.

Usage

Node-battery provides two methods:

var nodeBattery = require("node-battery");

nodeBattery.getBatteries(function(data){

	// Linux only
	// "data" Is an array containing paths to the battery files
});

nodeBattery.percentages(function(data){

	// "data" Is an array containing a percentage of power left for each battery.
});

nodeBattery.isCharging(function(data){

	// "data" Is an array containing a 0 or a 1 depending on wheter the battery is being charged.
});

On Linux this module works by reading out the BAT* files in '/sys/class/power_supply'.

If no batteries are detected this could be caused by the fact that your BAT* files start with BAT0 instead of BAT1, to fix this just pass in a 0 as the second argument.

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.1

11 years ago

0.1.0

11 years ago