fix(tmux): parse macOS battery status#111
Draft
ALX99 wants to merge 1 commit into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem and impact
On macOS, the tmux status script rendered an empty battery percentage because its extended-regex parser used
\d, which POSIXgrep -Edoes not define as a digit class. It also matchedcharginginsidedischarging, so a low discharging battery could use the charging colour instead of the warning/critical colour.Reproduction and observed result
Validated against untouched
mastercommit52ea8ecd508b4cb3cc529a3c6d3f69696cbf2060with the exact current script in a fresh temporary Git repository. Temporaryunameandpmsetstubs selected the real Darwin branch and emitted standard battery rows.With
12%; discharging, the parent printed:With
87%; charging, it also printed an empty percentage. Directly running the parent expression with GNU grep 3.11 produced no match for87%.Root cause and fix
The Darwin parser used
grep -Eo "\d+%"and an unbounded case-insensitive search forcharging.The fix uses the portable ERE
[0-9]+%and matcheschargingonly as a complete semicolon/whitespace-delimited status word. Linux battery handling and status-line assembly are unchanged.Validation commands and results
bash -n .config/tmux/status— passed.12%; discharging→12%with the critical colour.87%; charging→87%with the charging colour.100%; charged→100%without being misclassified as charging.git diff --check— passed.master— one commit, zero commits behind, one modified file, two additions and two deletions.Linterworkflow (ShellCheck across all shebang files) — passed.Scope and risk
Only
.config/tmux/statuschanges. No tests, configuration contracts, Linux behavior, generated files, dependencies, or unrelated code are modified. The risk is limited to parsingpmset -g batttext on macOS.