The below command outputs a lot status and statistical information about the battery. The /org/... path can be found with the command upower -e (--enumerate).
Or for a more verbose output that constantly updates:
watch --interval=5 acpi -V
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
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:
#!/bin/bash
# Description: Battery charge in percentage
grep POWER_SUPPLY_CAPACITY /sys/class/power_supply/BAT1/uevent
The output for executing this ( ./batpower ) is going to be something like this:
POWER_SUPPLY_CAPACITY=23
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:
#!/bin/bash
# Description: Battery charge in percentage
if [ -f /sys/class/power_supply/BAT1/uevent ]
then grep POWER_SUPPLY_CAPACITY /sys/class/power_supply/BAT1/uevent
else echo "Battery isn't present"
fi
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 !
The below command outputs a lot status and statistical information about the battery. The
/org/...
path can be found with the commandupower -e
(--enumerate
).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
upower -d
(--dump
) command that shows information for all available power resources such as laptop batteries, external mice, etc.A friendly reminder: since Linux kernel 2.6.24 using
/proc
to store ACPI info has been discouraged and deprecated.Now we are encouraged to use ->
/sys/class/power_supply/BAT0
.UPDATE: Linux 3.19 and onwards, we should look at the following directory ->
/sys/class/power_supply/BAT1/
For example, checking capacity & status running
Linux 4.20
and
Linux 5.9
DEPRECATED - thanks @morhook
First install
acpi
by running this command,Then run:
Sample output:
Or for a more verbose output that constantly updates:
Output:
Thanks to @Wilf this works on my Ubuntu 17.10 on Lenovo Yoga 720:
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
Here is an article on a package that can check your battery life at the command line.
Basically, all you have to do is:
Maybe you can try:
cat /proc/acpi/battery/BAT0/state
cat /proc/acpi/battery/BAT0/info
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 !
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.
You can either type :
or
or with the distrib's inxi package (more up to date from the inxi official source code here)