Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Battery regex in example doesn't handle 100% #476

Open
kuon opened this issue Aug 10, 2023 · 2 comments
Open

Battery regex in example doesn't handle 100% #476

kuon opened this issue Aug 10, 2023 · 2 comments

Comments

@kuon
Copy link

kuon commented Aug 10, 2023

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

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

@gportay
Copy link
Contributor

gportay commented Aug 10, 2023

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.

@mcassisa
Copy link

mcassisa commented Nov 4, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants