Skip to content

Gate Lenovo-only features off on unsupported laptops and cut background CPU#3

Merged
lenuswalker merged 1 commit into
processor-controllerfrom
claude/stupefied-varahamihira-a396ba
Jun 13, 2026
Merged

Gate Lenovo-only features off on unsupported laptops and cut background CPU#3
lenuswalker merged 1 commit into
processor-controllerfrom
claude/stupefied-varahamihira-a396ba

Conversation

@lenuswalker

Copy link
Copy Markdown
Owner

Summary

On unsupported (non-Lenovo) machines, several Lenovo-specific components started unconditionally at launch and consumed resources (and quietly failed). This change gates them behind the existing basic-compatibility check and trims always-on background work.

Lenovo-only feature gating

  • Added Compatibility.IsBasicCompatible — a synchronous view of the cached basic-compat result — and a new AutoActivateLenovoListener() registration extension that skips auto-activation on unsupported hardware.
  • App now resolves basic compatibility before building the IoC container, so the gate is known at module-load time.
  • The 7 Lenovo WMI/driver listeners (DriverKey, LightingChange, PowerMode, RGBKeyboardBacklight, SpecialKey, ThermalMode, WinKey) now use the gated extension and never start on unsupported machines. The 6 generic listeners (DisplayBrightness, DisplayConfiguration, NativeWindowsMessage, PowerState, SessionLockUnlock, SystemTheme) keep normal auto-activation.
  • Moved hybrid-mode init, AIController, the battery discharge-rate monitor, HWiNFO integration, and macro init inside the if (_isCompatible) block.
  • Cross-platform features this fork relies on — power-mode Windows-overlay fallback, processor TDP automation, CLI/IPC, and discrete-GPU keep-off — remain available on any laptop.

Performance

  • MacroController installs the system-wide WH_KEYBOARD_LL hook only when macros are enabled (default off), eliminating a per-keystroke managed callback on every machine. Install/uninstall is confined to the UI thread (startup + MacroPage toggle); SetEnabled only flips the setting because automation steps run off-thread. Added Stop() and shutdown cleanup.
  • Removed dead-code guards in BatteryDischargeRateMonitorService.

Security

No new attack surface — the change reduces it: fewer WMI subscriptions and no global keyboard hook unless the user explicitly enables macros. No new I/O, P/Invoke, or external calls.

Testing

  • Full solution builds with 0 errors (dotnet build LenovoLegionToolkit.sln).
  • Ran the built app locally; launched stable, idle CPU settles low, Lenovo-only background activity skipped on unsupported hardware.

Note

If macros are disabled at startup and an automation pipeline enables them mid-session, the hook won't install until the UI toggle is used or the app restarts (the setting persists). This is the deliberate trade-off for not installing a global keyboard hook from a background thread.

🤖 Generated with Claude Code

…nd CPU

On unsupported (non-Lenovo) machines, several Lenovo-specific components
started unconditionally and consumed resources:

- Seven Lenovo WMI/driver event listeners were auto-activated during IoC
  container build regardless of hardware.
- Hybrid mode init, AIController, the HWiNFO sensor integration, and the
  battery discharge-rate monitor ran outside the compatibility gate.

Changes:
- Add Compatibility.IsBasicCompatible (synchronous view of the cached
  basic-compat result) and an AutoActivateLenovoListener() registration
  extension that skips auto-activation on unsupported hardware. App now
  resolves compatibility before building the container so the gate is set
  at module-load time. The 7 Lenovo listeners use the gated extension; the
  6 generic listeners keep normal auto-activation.
- Move hybrid mode, AIController, battery monitor, HWiNFO, and macro init
  inside the compatible block. Cross-platform features (power-mode Windows
  fallback, processor TDP automation, CLI/IPC, GPU keep-off) stay available
  on any laptop.

Performance:
- MacroController installs the system-wide WH_KEYBOARD_LL hook only when
  macros are enabled (default off), eliminating per-keystroke managed
  callbacks on every machine. Hook install/uninstall is confined to the UI
  thread (startup + MacroPage toggle); SetEnabled only flips the setting
  because automation steps run off-thread. Added Stop() and shutdown cleanup.
- Remove dead-code guards in BatteryDischargeRateMonitorService.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@lenuswalker lenuswalker merged commit 48771aa into processor-controller Jun 13, 2026
1 check passed
@lenuswalker lenuswalker deleted the claude/stupefied-varahamihira-a396ba branch June 13, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant