Skip to content

Read CPU usage from top in the C locale - #15109

Merged
omarchybot merged 1 commit into
quattrofrom
fix/issue-12315
Oct 31, 2026
Merged

omarchybot merged 1 commit into
quattrofrom
fix/issue-12315

Conversation

@omarchybot

Copy link
Copy Markdown
Collaborator

The system panel's CPU reading came from parsing top -bn1 in the user's own locale, and bin/omarchy-system-stats read it wrong in three ways:

  • A decimal-comma locale such as es_ES.UTF-8 prints idle as 84,3 id. The awk deleted every comma, so it read 843 and showed CPU at -743%.
  • A locale whose procps catalog translates the labels (German and Brazilian Portuguese print %CPU(s)) never matched /^%?Cpu/, so the panel got no reading at all.
  • At full idle top writes 0.0 ni,100.0 id with no space. Deleting the comma glued the two fields into ni100.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.

top now runs under LC_ALL=C, which fixes the labels and the decimal point together and also overrides an LC_ALL the 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-widget path reads /proc/stat directly and is unaffected.

test/shell.d/system-stats-test.sh stubs top with the summary line as procps prints it in Spanish, German and C. On current quattro those cases read -743%, empty and 100%. With this change they read 16%, 16% and 0%.

Fixes #12315

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>
@greptile-apps

greptile-apps Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Makes the system panel’s CPU reading independent of the user’s locale.

  • CPU readings stay accurate across locales and at full idle.

No actionable issues found. Tests were inspected but not run.

Reviews (1) · Last reviewed commit: "Read CPU usage from top in the C locale" · Reviewed by Greptile

@omarchybot omarchybot added bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Oct 17, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator Author

Reviewed and verified on a fresh Omarchy worker VM, with this branch merged onto current quattro (33783b1).

Reproduction with the real top. With es_ES.UTF-8, de_DE.UTF-8 and pt_BR.UTF-8 generated on the worker and the CPU under load, omarchy-system-stats on quattro read -641% under Spanish and gave no CPU reading at all under German and Brazilian Portuguese, where procps prints %CPU(s). With this change it read 26% in every locale, matching top's own idle figure. Reverting just the bin/omarchy-system-stats change brings the -629% and the empty readings back. The fully idle case (ni,100.0 id) could not be produced on a live VM, so it rests on the stubbed top in the new test.

Tests. test/shell.d/system-stats-test.sh fails on quattro (-743%) and passes with the change. ./test/cli is green. Of 449 shell test files, 439 pass; the other 10 (ascii, background-instant-reload, background-intro-clone, branding-about-animation, hyprland-startup-cursor-cold, i18n, lock-appear-budget, passwordless-grant-lifecycle, runtime-smoke, screenshot-sanity) fail the same way on quattro without this change, and none of them touch system stats.

Second opinion. Codex Medium reviewed the diff and found nothing to fix. It also checked that each half of the change is needed: without LC_ALL=C the Spanish and German cases still fail, and without the comma-to-space change the idle case still reads 100%. The panel's only consumer, shell/plugins/panels/power/Model.js, reads the same tab-separated output as before. It agreed with my conclusions, and its independence is not guaranteed.

No competing pull requests found. This fixes #12315 and is now waiting on the maintainer.

@omarchybot
omarchybot merged commit c304026 into quattro Oct 31, 2026
1 check passed
@emirb emirb added this to the 4.5 milestone Nov 5, 2026
berenddeboer pushed a commit to berenddeboer/omarchy that referenced this pull request Nov 6, 2026
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

omarchy-system-stats reports wildly wrong (negative) CPU% under decimal-comma locales (es_ES, etc.)

2 participants