Code Monkey home page Code Monkey logo

battinfo's Introduction

battinfo

nimble

Introduction

A simple command line utility and a nim library to discover batteries in your GNU/Linux machine and print it's information in the console.

Get Started

Install using nimble package manager

  $ nimble install battinfo

Note: One can also install without nimble directly by downloading either the 64-bit executable binary or .deb package for Debian/Ubuntu based distros from the releases

Using as cli tool

  # discovers batteries and displays their info
  $ battinfo

Using battinfo as library in your Nim program

import battinfopkg/battery

var batteries: seq = get_batteries()  # returns a sequence of battery files found in the system.
echo batteries

if batteries.len > 0:
  # following procedures accept battery file path as argument
  echo get_status(batteries[0])          # returns charging/discharging status as string
  echo get_manufacturer(batteries[0])    # returns the name of the manufacturer as string
  echo get_model(batteries[0])           # returns the battery model as string
  echo get_tech(batteries[0])            # returns the type of battery as string
  echo get_serial(batteries[0])          # returns serial info of the battery as string
  echo get_percentage(batteries[0])      # returns battery percentage left as int
  echo get_current_charge(batteries[0])  # returns the current charge as float
  echo get_total_capacity(batteries[0])  # returns the total capacity of the battery as float

License

This software is offered as a Free Software under the terms of GNU General Public License version 3.

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.