Repository navigation
Read CPU usage from top in the C locale - #15109
Conversation
The system panel parsed top's summary line in the user's locale. A decimal-comma locale prints idle as "84,3", which deleting commas turned into 843, so es_ES showed CPU at -743%; a locale that translates the labels (de_DE prints "%CPU(s)") gave no reading at all. Wherever the label matched, a fully idle machine read as 100%, because top writes "ni,100.0 id" with no space and deleting the comma glued the two fields together. Running top under LC_ALL=C pins both the labels and the decimal point, and overrides an LC_ALL the user set, which LC_NUMERIC alone would not. With commas then only separators, they become spaces rather than nothing. Fixes #12315 Co-Authored-By: Codex Medium <noreply@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
Reviewed and verified on a fresh Omarchy worker VM, with this branch merged onto current Reproduction with the real Tests. Second opinion. Codex Medium reviewed the diff and found nothing to fix. It also checked that each half of the change is needed: without No competing pull requests found. This fixes #12315 and is now waiting on the maintainer. |
The system panel parsed top's summary line in the user's locale. A decimal-comma locale prints idle as "84,3", which deleting commas turned into 843, so es_ES showed CPU at -743%; a locale that translates the labels (de_DE prints "%CPU(s)") gave no reading at all. Wherever the label matched, a fully idle machine read as 100%, because top writes "ni,100.0 id" with no space and deleting the comma glued the two fields together. Running top under LC_ALL=C pins both the labels and the decimal point, and overrides an LC_ALL the user set, which LC_NUMERIC alone would not. With commas then only separators, they become spaces rather than nothing. Fixes omacom#12315 Co-authored-by: Omarchybot <317366263+omarchybot@users.noreply.github.com> Co-authored-by: Codex Medium <noreply@openai.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit c304026)
The system panel's CPU reading came from parsing
top -bn1in the user's own locale, andbin/omarchy-system-statsread it wrong in three ways:es_ES.UTF-8prints idle as84,3 id. The awk deleted every comma, so it read 843 and showed CPU at -743%.%CPU(s)) never matched/^%?Cpu/, so the panel got no reading at all.0.0 ni,100.0 idwith no space. Deleting the comma glued the two fields intoni100.0, which awk takes as 0, so an idle machine read as 100% busy. This happens in every locale where the label matches, English included.topnow runs underLC_ALL=C, which fixes the labels and the decimal point together and also overrides anLC_ALLthe user has set (LC_NUMERIC=C, as the issue suggests, would lose to that). With commas left only as separators, they are replaced by spaces rather than deleted. The--bar-widgetpath reads/proc/statdirectly and is unaffected.test/shell.d/system-stats-test.shstubstopwith the summary line as procps prints it in Spanish, German and C. On currentquattrothose cases read -743%, empty and 100%. With this change they read 16%, 16% and 0%.Fixes #12315