The upower
command is a tool in Linux for monitoring and managing power usage on the system. It provides information about the state of the battery, the power supply, and other power-related information.
Here are some common examples of how to use the upower
command:
- Get a list of all power devices on the system:
upower -e
- Get detailed information about a specific power device:
upower -i <device>
Replace <device>
with the device name, which can be obtained from the list of power devices obtained in example 1.
- Get the current battery percentage:
upower -d | grep percentage | awk '{print $2}'
- Get the battery state (discharging, charging, etc.):
upower -d | grep state | awk '{print $2}'
- Monitor the battery percentage in real-time:
watch -n 1 upower -d | grep percentage | awk '{print $2}'
These are just a few examples of how you can use the upower
command to monitor and manage power usage on your system. You can find more information about the command by running man upower
in the terminal.