How to check the power level of your laptop battery

I came across an interesting Linux command recently, and I wanted to share it with you. If you run Linux on your laptop and want to check the power level of your laptop battery, you can do it from the graphical user interface (GUI). However, I bet you didn’t know that you can do it from the command line as well. In this tutorial, I will show you how you can check the power level of your laptop battery from the command line interface (CLI).

Gulian Technology
Gulian Technology

How to check the power level of your laptop battery from the graphical user interface (GUI)

In Ubuntu, press the ‘Show Apps’ button in the left-down corner and write settings in the search field.

Show Apps
Show Apps
Type to search
Type to search
Settings
Settings

A new window will be opened, similar to the one below.

Power Settings window
Power Settings window

If you want more information about the battery level, run the command gnome-power-statistics in the CLI.

petru@petru-lap:~$ gnome-power-statistics 
petru@petru-lap:~$

It will open a new window similar to the one below.

gnome-power-statistics

How to check the power level of your laptop battery
gnome-power-statistics
Details about the laptop battery level
Details about the laptop battery level

How to check the power level of your laptop battery from the command line interface (CLI)

You can find similar details by running the command upower on the command line interface (CLI). The beauty is that this command is already installed and present on most Linux distributions, so you won’t need to waste time installing it.

To find out more information about the upower command, you can check its man page.

petru@petru-lap:~$ man upower
petru@petru-lap:~$ 
UPOWER(1)                                        upower                                       UPOWER(1)

NAME
       upower - UPower command line tool

SYNOPSIS

       upower [--dump] [--enumerate] [--monitor-detail] [--monitor] [--show-info] [--version] [--help]

DESCRIPTION
       upower is a simple command line client for the UPower(7) daemon. TODO: not fully documented.

OPTIONS
       --monitor
           Connect to the UPower daemon and print a line every time a power source is added, removed or
           changed.

       --monitor-detail
           Like --monitor but prints the full details of the power source whenever an event happens.

       --help
           Show help options.

AUTHOR
       Written by David Zeuthen <davidz@redhat.com> with a lot of help from many others.
 Manual page upower(1) line 1 (press h for help or q to quit)
upower man page
upower man page

You can also run upower -h to see the help page and what options you can use with it.

petru@petru-lap:~$ upower -h
Usage:
  upower [OPTION…] UPower tool

Help Options:
  -h, --help           Show help options

Application Options:
  -e, --enumerate      Enumerate objects paths for devices
  -d, --dump           Dump all parameters for all objects
  -m, --monitor        Monitor activity from the power daemon
  --monitor-detail     Monitor with detail
  -i, --show-info      Show information about object path
  -v, --version        Print version of client and daemon

petru@petru-lap:~$
upower help page
upower help page

To find the devices present on your host, you need to run the command upower –enumerate.

petru@petru-lap:~$ upower --enumerate
/org/freedesktop/UPower/devices/battery_BAT0
/org/freedesktop/UPower/devices/battery_hidpp_battery_0
/org/freedesktop/UPower/devices/line_power_AC
/org/freedesktop/UPower/devices/DisplayDevice
petru@petru-lap:~$ 
Check the devices present on your host
Check the devices present on your host

To check the power level of your laptop battery from the command line interface (CLI), run the below command.

petru@petru-lap:~$ upower --show-info /org/freedesktop/UPower/devices/battery_BAT0
  native-path:          BAT0
  vendor:               Hewlett-Packard
  model:                Primary
  serial:               02080 2019/08/11
  power supply:         yes
  updated:              Mon 16 Sep 2024 12:45:15 PM BST (19 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               charging
    warning-level:       none
    energy:              35.343 Wh
    energy-empty:        0 Wh
    energy-full:         38.4846 Wh
    energy-full-design:  38.4846 Wh
    energy-rate:         9.36705 W
    voltage:             13.159 V
    charge-cycles:       N/A
    time to full:        20.1 minutes
    percentage:          91%
    capacity:            100%
    technology:          lithium-ion
    icon-name:          'battery-full-charging-symbolic'
  History (rate):
    1726487115	9.367	charging
    1726487085	9.506	charging
    1726487055	9.667	charging
    1726487039	9.748	charging

petru@petru-lap:~$ 
Check the power level of your laptop battery from the command line interface (CLI)

How to check the power level of your laptop battery
Check the power level of your laptop battery from the command line interface (CLI)

In the command output, you can find when the command was run and information about the battery. The above output is from a healthy battery.

The output for an unhealthy battery will look like the screenshot below.

┌──(petru㉿kalap)-[~]
└─$ upower -i /org/freedesktop/UPower/devices/battery_BAT1
  native-path:          BAT1
  vendor:               SANYO
  model:                42T4763
  serial:               30959
  power supply:         yes
  updated:              Mon 16 Sep 2024 12:50:17 BST (1 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               charging
    warning-level:       none
    energy:              0 Wh
    energy-empty:        0 Wh
    energy-full:         0 Wh
    eneregy-full-design:  0 Wh
    energy-rate:         0 W
    voltage:             14.981 V
    charge-cycles:       N/A
    percentage:          0%
    technology:          lithium-ion
    icon-name:          'battery-caution-charging-symbolic'
Output for an unhealthy battery
Output for an unhealthy battery

As you can see in the screenshot above, the values for energy, energy-empty, energy-full, energy-full-design and energy-rate are zero. Compare them to the output from the HP laptop.

To see the information for all devices connected to your laptop, you can run the upower -d command. It will dump the information for all present devices.

Power details for all connected devices
Power details for all connected devices
petru@petru-lap:~$ upower -d
Device: /org/freedesktop/UPower/devices/battery_BAT0
  native-path:          BAT0
  vendor:               Hewlett-Packard
  model:                Primary
  serial:               02080 2019/08/11
  power supply:         yes
  updated:              Mon 16 Sep 2024 12:57:39 PM BST (24 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               charging
    warning-level:       none
    energy:              36.96 Wh
    energy-empty:        0 Wh
    energy-full:         38.4846 Wh
    energy-full-design:  38.4846 Wh
    energy-rate:         6.45645 W
    voltage:             13.174 V
    charge-cycles:       N/A
    time to full:        14.2 minutes
    percentage:          96%
    capacity:            100%
    technology:          lithium-ion
    icon-name:          'battery-full-charging-symbolic'
  History (charge):
    1726487859	96.000	charging
  History (rate):
    1726487859	6.456	charging
    1726487829	6.549	charging
    1726487799	6.641	charging

Device: /org/freedesktop/UPower/devices/battery_hidpp_battery_0
  native-path:          hidpp_battery_0
  model:                Wireless Mouse M185
  serial:               03-e8-c0-b4
  power supply:         no
  updated:              Mon 16 Sep 2024 12:57:39 PM BST (24 seconds ago)
  has history:          yes
  has statistics:       yes
  mouse
    present:             yes
    rechargeable:        yes
    state:               unknown
    warning-level:       none
    battery-level:       unknown
    percentage:          50% (should be ignored)
    icon-name:          'battery-missing-symbolic'

Device: /org/freedesktop/UPower/devices/line_power_AC
  native-path:          AC
  power supply:         yes
  updated:              Mon 16 Sep 2024 12:20:47 PM BST (2236 seconds ago)
  has history:          no
  has statistics:       no
  line-power
    warning-level:       none
    online:              yes
    icon-name:          'ac-adapter-symbolic'

Device: /org/freedesktop/UPower/devices/DisplayDevice
  power supply:         yes
  updated:              Mon 16 Sep 2024 12:57:39 PM BST (24 seconds ago)
  has history:          no
  has statistics:       no
  battery
    present:             yes
    state:               charging
    warning-level:       none
    energy:              36.96 Wh
    energy-full:         38.4846 Wh
    energy-rate:         6.45645 W
    charge-cycles:       N/A
    time to full:        14.2 minutes
    percentage:          96%
    icon-name:          'battery-full-charging-symbolic'

Daemon:
  daemon-version:  1.90.3
  on-battery:      no
  lid-is-closed:   no
  lid-is-present:  yes
  critical-action: HybridSleep
petru@petru-lap:~$ 

In the above output, you can see the power level for my wireless mouse as well.

To check the application version, run upower -v.

petru@petru-lap:~$ upower -v
UPower client version 1.90.3
UPower daemon version 1.90.3
petru@petru-lap:~$
upower version
upower version

That’s it! You have learned how to check the power level of your laptop battery both from the graphical user interface and the command line interface. If you found this blog post helpful, please like and subscribe for more Linux tutorials. Thank you for reading it!

What method do you use for checking the power level on your device? Please tell me in the comments section.

Processing…
Success! You're on the list.

Leave a Reply