Better regex for battery level detection

Detect the battery level, whether or not it is followed by decimals
This commit is contained in:
Lucien Cartier-Tilet 2021-05-21 21:12:27 +02:00
parent 763d459a9e
commit e9136b77cd
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA
1 changed files with 1 additions and 1 deletions

View File

@ -434,7 +434,7 @@ the warning face with a battery level of 25% or less."
(if (string= battery-level "Battery status not available")
""
(let ((percentage (save-match-data
(string-match "\\([0-9]+\\)\\.[0-9]+%" battery-level)
(string-match "\\([0-9]+\\)\\(\\.[0-9]\\)?%" battery-level)
(string-to-number (substring battery-level (match-beginning 1) (match-end 1))))))
(concat (s-pad-right text-padding "." "Battery")
": "