i3blocks icon indicating copy to clipboard operation
i3blocks copied to clipboard

Battery regex in example doesn't handle 100%

Open kuon opened this issue 2 years ago • 2 comments

Regex should be changed to support one to three digits number.

BAT=$(acpi -b | grep -E -o '[0-9][0-9]?[0-9]?%')

kuon avatar Aug 10 '23 02:08 kuon

BAT=$(acpi -b | grep -E -o '[0-9][0-9]?[0-9]?%')

Oh, true. I guess the following is even more appropriate.

BAT=$(acpi -b | grep -E -o '[0-9]{1,3}%')

However, I do not recall il the braces should be escaped.

gportay avatar Aug 10 '23 08:08 gportay

if acpi isn't installed the battery charge can be found using grep -P -o '(?<=^POWER_SUPPLY_CAPACITY=)\w*$' /sys/class/power_supply/BAT0/uevent

mcassisa avatar Nov 04 '23 15:11 mcassisa