Skip to content

Battery performance visualizer for Arch Linux systems. Reads data from the sys power_supply files.

Notifications You must be signed in to change notification settings

neymarsabin/batterarch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BatterArch

Check battery performance of your laptop if you are running Arch Linux. This binary at the moment does not consider any other OS except Arch.

How it works?

The applications reads the file /sys/class/power_supply/BAT0/uevent and saves the data into a SQlite db table. The file looks something like this:

cat /sys/class/power_supply/BAT0/uevent

# POWER_SUPPLY_NAME=BAT0
# POWER_SUPPLY_TYPE=Battery
# POWER_SUPPLY_STATUS=Discharging
# POWER_SUPPLY_PRESENT=1
# POWER_SUPPLY_TECHNOLOGY=Li-poly
# POWER_SUPPLY_CYCLE_COUNT=14
# POWER_SUPPLY_VOLTAGE_MIN_DESIGN=11520000
# POWER_SUPPLY_VOLTAGE_NOW=11178000
# POWER_SUPPLY_POWER_NOW=8014000
# POWER_SUPPLY_ENERGY_FULL_DESIGN=57000000
# POWER_SUPPLY_ENERGY_FULL=58030000
# POWER_SUPPLY_ENERGY_NOW=17210000
# POWER_SUPPLY_CAPACITY=29
# POWER_SUPPLY_CAPACITY_LEVEL=Normal
# POWER_SUPPLY_MODEL_NAME=LNV-5B11C73244
# POWER_SUPPLY_MANUFACTURER=SMP
# POWER_SUPPLY_SERIAL_NUMBER=772

Building BatterArch

Make sure you have golang installed because the application is written in Golang. To build run the following command:

go build .

This will create a binary called batterarch that we can run in the terminal.

Usage

Now that you have the binary ready, there are multiple ways you can run the app. The binary comes up the following options:

./batterarch <options>

options can be one of the following:
g => graph => view usage graph in the browser.
j => json => view usage data as JSON in the stdout/terminal.
s => server => start a TCP server in port 42069 that has routes

Server Details

When you spin up a batterarch server, the API responds to JSON in http://localhost:42069/

curl -X GET http://localhost:42069/ | jq ".data[] | .BatteryLevel"

Data Storage

BatterArch uses sqlite database as data storage. All the data that we get in the graph, json or server mode are retrieved using SQL queries from the SQlite database. The location of the database is $HOME/.config/batterarch/batterarch.db The config folder and database is automatically created. If you want to write your own queries against the database, you can explore the batterarch.db file and write SQL queries.

About

Battery performance visualizer for Arch Linux systems. Reads data from the sys power_supply files.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published