Skip to content

A shell function that gives battery statistics on a Linux Laptop

License

Notifications You must be signed in to change notification settings

izcet/linux_battery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

linux laptop battery function

screenshot
To use this function, add the following line to your .*rc (I use .bashrc, the syntax may need to be changed for other shells).

source /path/to/this/repo/battery.sh

About

  • The output format is <battery status> <capacity percentage> (HH:MM remaining)
  • This shell function reads the system files from /sys/class/power_supply/... and does some math and text manipulation to provide human readable output on various battery statistics.
  • The time is most accurate when the power source is the battery and not the charger.
  • The time calculation is based on your current power usage, so it will appear to suddenly have more battery life if you stop a lot of processes (as you would expect).
  • The script is protected against a divide-by-zero error when the power source changes while the script is running.

About

A shell function that gives battery statistics on a Linux Laptop

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages