GithubHelp home page GithubHelp logo

neymarsabin / batterarch Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 24 KB

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

Go 94.18% Makefile 5.82%
archlinux golang thinkpad

batterarch's Introduction

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.

batterarch's People

Contributors

neymarsabin avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.