I would like a command that check the battery status through the terminal
|
The below command outputs a lot status and statistical information about the battery. The
Example output:
You could use tools like grep to get just the information you want from all that output. One simple way: piping the above command into
outputs:
If you would often like to run that command, then you could make a Bash alias for the whole command. Example:
Add that to the end of your .bashrc file, and you can type 'bat' any time, in the terminal. There is also a |
|||||||||||||||||||||
|
|
A friendly reminder: since Linux kernel 2.6.24 using Now we are encouraged to use -> UPDATE: Linux 3.19 and onwards, we should look at the following directory -> For example
capacity -> |
||||
|
|
|
First install
Then run:
Sample output:
Or for a more verbose output that constantly updates:
Output: Every 5.0s: acpi -V Wed Jan 8 15:45:35 2014 Battery 0: Full, 100% Adapter 0: on-line Thermal 0: ok, 44.0 degrees C Thermal 0: trip point 0 switches to mode critical at temperature 127.0 degrees C Thermal 0: trip point 1 switches to mode hot at temperature 127.0 degrees C Cooling 0: intel_powerclamp no state information available Cooling 1: pkg-temp-0 no state information available Cooling 2: LCD 100 of 100 Cooling 3: LCD 100 of 100 Cooling 4: Processor 0 of 10 Cooling 5: Processor 0 of 10 Cooling 6: Processor 0 of 10 Cooling 7: Processor 0 of 10 Cooling 8: Processor 0 of 10 Cooling 9: Processor 0 of 10 Cooling 10: Processor 0 of 10 Cooling 11: Processor 0 of 10 |
||||
|
|
|
Thanks to @Wilf this works on my Ubuntu 14.04 on Lenovo Yoga 2 Pro:
Output:
Or just the numeric value with this one liner
|
|||||
|
|
It's enough to type the command
For detailed information you can type
I didn't have to install any packages before. System: Debian 7.2 64bit |
||||
|
|
|
Maybe you can try:
|
|||||
|
|
Here is an article on a package that can check your battery life at the command line. Basically, all you have to do is:
|
||||
|
|
|
I'm a little late to the party but here's my little contribution. Based on the previous answers , I have made a simple script batpower:
The output for executing this ( ./batpower ) is going to be something like this:
N.B. : the batery number may be different for you, in my case it is BAT1, but you can always find it out by cd'ing to /sys/class/power_supply or as Lekensteyn mentioned through upower -e My machine : Ubuntu 13.10 , 3.11.0 Replace BAT1 in the above bash code to BAT0 if you have older version Ubuntu i.e. 13.04 or later. IMPROVED SCRIPT: Since my original post, I've made a small improvement to the script:
As always, pay attention to spaces with bash. This is all self explanatory. If battery is present, it will show up, if not - the script will tell you so. Now, go to your .bashrc file and add $(batpower) to your prompt. Here's mine promt:
Update your terminal or open new tab or window, and now you can monitor battery charge constantly in terminal ! including tty ! May the scripting be praised !
|
|||||||||
|
|
Run the following command in a terminal for getting detailed info:
If you just want the state do:
|
|||||
|
|
You can do it without installing any extra packages:
This command is lifted from byobu's source. It might be a good candidate for a Bash alias. |
|||||
|
|
Install acpi, then use E.g.
will show the information such as below and will update every 5 seconds.
Question is why would someone do this? Well, I have a laptop with broken LCD screen that I am now using as my bittorrent box. |
||||
|
|
|
I was going to suggest Please type this in your terminal:
If you get a "file or directory not found" then this isn't going to work. But, if it lists files, then here's a script [paste it into /usr/games/ or other directory in $PATH, and run (Note, if not already installed, install the program
I have tested this script on my laptop. I say estimate above because **In my lenovo, the battery is listed as BAT1, try that too. (12.04 LTS) |
|||||||||||||
|
|
This did the job for me in ubuntu 14.04:
|
||||
|
|
|
Similar script without calc or apcalc:
|
|||
|
|
|
This won't help everyone, but it did me - I use byobu whenever I am using a terminal, and battery is one of the options for the status notifications bar. |
|||
|
|
|
Here is what I use. It just looks at the diff between full charge and current charge as well as seeing if the charge is dropping in which case it uses notify to alert the user.
|
|||
|
|
|
|||||
|
|
This works:
|
|||||||||
|
protected by Sergiy Kolodyazhnyy Oct 6 '16 at 5:56
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?

$ upower -i $(upower -e | grep 'BAT') | grep -E "state|to\ full|percentage"– Jake Berger Dec 4 '14 at 17:23