Code Monkey home page Code Monkey logo

i3battery's Introduction

i3battery

CircleCI

LOGO

I made this script for my configuration of i3wm because in this distro there isn't a battery warning notifier.

This script regularly checks your battery charge and shows a warning in a text notify and if abilitate also an audio warning if you are about to completely drain your battery.

Install

You need to clone the repository with:

git clone https://github.com/Wabri/i3battery

Then move into i3battery directory:

cd i3battery

And finally run and install i3battery:

./install.sh

Try to run the help command:

i3battery --help

If this return the commands list you can use than the i3battery is installed and you can use it.

To test notifications and audio you can use the arguments test:

i3battery --test-notify --test-audio

Configurations

There are some arguments that you can use to change the configuration:

  • --audio to abilitate audio (default=disable)
  • --audio_path=<path_to_audio_directory> to specify the audio directory (default=.config/i3battery/audio/)
  • --no-notify to disabilitate notifications (default=abilitate)
  • --wt=<wt1>,<wt2>,<wt3> to set the warning threshold to different values (default=20,15,5)
  • --time=<value> to define the time of cycle (default=20)
  • --power-path=<value> to specify the path of the system class power supply (default=/sys/class/power_supply/)
  • --bat=<value> to specify the battery you want to use (default=BAT0)

Here is an example:

i3battery --audio --audio-path=/home/wabri/.config/i3battery/audio/ --wt=77,78,76 --time=7 --power-path=/sys/class/power_supply/ --bat=BAT0

The default audio warning is installed on ~/.config/i3battery/audio/, you can change by override the files inside it (Warning: need to be wav files):

  • warning.wav -> use when reach one of the threshold
  • plug-in.wav -> use when the adapter goes online
  • plug-out.wav -> use when the adapter goes offline

I3 users

To use this on i3wm you need to append to your i3 config file this line:

exec --no-startup-id i3battery

The most common use is audio without notifications:

exec --no-startup-id i3battery --audio --no-notify

You can configure the running with the configurations below.

How to make sure the used battery is the right one

Execute this command on terminal:

ls /sys/class/power_supply/ | grep "BAT"

This can have multiple output:

  1. The output is not null and return only the BAT0 string, you don't need to do anything else and you can use the script as is.

  2. You have more than one batteries the output will be something like this:

    BAT0 BAT1 BAT2

    In this case you need to specify what battery you want to use for this script by adding this argument:

    i3battery --bat=BAT2
  3. You have no output, this is the hard one. Maybe your power supply are stored in other path, than you need to find it and add the argument for that path:

    i3battery --power-path=/sys/class/power_supply/

    Make sure to use the right battery even in this case (e.g. BAT1, BAT0)

i3battery's People

Contributors

wabri avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

i3battery's Issues

Refactor i3battery.py

  • rename private methods and variables

  • create the run method from this:

    while True:

    and add it to:

    if __name__ == "__main__":
        run()
    
  • Create some sort of documentations for methods

  • Use classes

cpu problem

I3battery after 4 hours of running consume 25% of cpu, maybe something is wrong...

Audio add

Add more audio for charger plug and for plug remove

Time to full

Find a way to calculate the time to full of battery

Help command

Need an help command to print all the commands and give infos about this utility script

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.