Skip to content

Add taskbar CPU/RAM stats and CPU temperature#812

Open
GiangQuan wants to merge 11 commits into
unchihugo:masterfrom
GiangQuan:codex/taskbar-system-stats
Open

Add taskbar CPU/RAM stats and CPU temperature#812
GiangQuan wants to merge 11 commits into
unchihugo:masterfrom
GiangQuan:codex/taskbar-system-stats

Conversation

@GiangQuan

@GiangQuan GiangQuan commented May 15, 2026

Copy link
Copy Markdown

Summary

This PR adds optional CPU/RAM stats to the taskbar widget, with optional CPU temperature display and a few compact styling controls for the taskbar text.

Preview

Taskbar CPU/RAM/temperature preview

What changed

  • Adds a two-line system stats block inside the existing taskbar widget:
    • CPU 18%
    • RAM 64%
    • optionally CPU 18% · 72°C
  • Adds settings to enable/disable the stats, choose whether the stats sit on the left or right side of the media content, and tune the taskbar text font, size, and color.
  • Keeps the existing media widget behavior intact; stats are hidden when the taskbar widget itself is disabled.
  • Adds tests for CPU usage calculations, compact formatting, temperature selection, monitor selection mapping, and style helper behavior.

How CPU/RAM stats work

CPU usage is sampled from Windows GetSystemTimes. The widget stores the previous idle/kernel/user values, compares them with the next sample, and formats the busy percentage as a compact line. RAM usage comes from GlobalMemoryStatusEx and uses Windows' memory load percentage.

The display updates on a lightweight one-second timer while the taskbar stats option is enabled. When the option is disabled, the timer stops.

How CPU temperature works

CPU temperature is optional and shown only when enabled in settings.

Temperature is read in this order:

  1. MSI Afterburner shared memory, when MSI Afterburner / RTSS monitoring data is available.
  2. LibreHardwareMonitor CPU sensors as a fallback.

For MSI Afterburner, the reader opens the MAHMSharedMemory memory map and prefers the known CPU temperature source id (0x00000080). If that source id is unavailable, it can also use monitoring entries whose name looks like CPU temperature. Invalid readings such as NaN, 0, negative values, or extreme values above 125C are ignored.

For LibreHardwareMonitor, the reader opens CPU hardware sensors and prefers package-style sensors such as CPU Package, Tctl/Tdie, Package, CPU Die, and Core Max. If none of those are available, it falls back to the hottest valid CPU temperature sensor.

Notes for review

  • Temperature display degrades gracefully to --°C when no supported sensor source is available.
  • The temperature line has a wider taskbar text column so values like CPU 18% · 72°C are not clipped.
  • Temperature color thresholds are handled separately from normal text color so warmer CPUs are easier to spot.

Validation

  • dotnet run --project FluentFlyoutWPF.Tests\FluentFlyoutWPF.Tests.csproj
  • dotnet build FluentFlyoutWPF\FluentFlyout.csproj -p:Platform=x64 -o %TEMP%\FluentFlyout-pr-cpu-ram-temp-build

Both commands pass locally. Existing nullable warnings remain, but no build errors are introduced.

@github-actions github-actions Bot added the Taskbar Widget Changes to the Taskbar Media Widget label May 15, 2026
@GiangQuan GiangQuan marked this pull request as ready for review May 15, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Taskbar Widget Changes to the Taskbar Media Widget

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant