Skip to content

Commit 55f0fa6

Browse files

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

scripts/battery_percentage.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ source "$CURRENT_DIR/helpers.sh"
77
print_battery_percentage() {
88
# percentage displayed in the 2nd field of the 2nd row
99
if is_wsl; then
10-
local battery
11-
battery=$(find /sys/class/power_supply/*/capacity | tail -n1)
12-
cat "$battery"
10+
if [ -e /sys/class/power_supply/*/capacity ]; then
11+
echo $(cat $(find /sys/class/power_supply/*/capacity | tail -n1))%
12+
fi
1313
elif command_exists "pmset"; then
1414
pmset -g batt | grep -o "[0-9]\{1,3\}%"
1515
elif command_exists "acpi"; then

0 commit comments

Comments
 (0)