Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions scripts/battery_percentage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ source "$CURRENT_DIR/helpers.sh"
print_battery_percentage() {
# percentage displayed in the 2nd field of the 2nd row
if is_wsl; then
local battery
battery=$(find /sys/class/power_supply/*/capacity | tail -n1)
cat "$battery"
local battery=$(find /sys/class/power_supply/*/capacity | tail -n1)
if [ -n "$battery" ]; then
echo $(cat "$battery")%
return
fi
elif command_exists "pmset"; then
pmset -g batt | grep -o "[0-9]\{1,3\}%"
elif command_exists "acpi"; then
Expand Down