This repository has been archived on 2024-03-04. You can view files and clone it, but cannot push or open issues or pull requests.
linux/.config/bash/module/Battery.sh

13 lines
355 B
Bash
Raw Normal View History

2024-02-12 23:00:16 +03:00
# Print current battery charge in percents.
function battery_charge() {
head -c -1 /sys/class/power_supply/BAT*/capacity
echo '%'
}
# Get battery's remaining max capacity in percents.
function battery_capacity() {
local IFS=$'\n'
local battery=("$(upower --enumerate | grep battery_BAT)")
upower -i "${battery[0]}" | grep capacity | cut -d\ -f17
2023-12-07 00:42:06 +03:00
}