spacr.qt.laptop_mode

Measure hardware constraints and suppress the ambient backdrop for this process.

Hardware-based decisions use the usable CPU count, physical memory and the SPACR_LAPTOP_MODE override. GUI startup instead passes an explicit decision from the selected performance level; its hardware reading is diagnostic.

Suppression affects backdrop rendering. This module does not set worker-thread limits or analysis parameters, and it does not replace stored animation preferences.

apply sets SPACR_NO_BACKDROP when suppression is requested and the ambient backdrop is enabled. Disabling removes only a suppression created by this module; a pre-existing crash-recovery override is retained.

Functions

apply(→ Dict[str, object])

Apply process-local backdrop suppression and report the decision and actions.

describe(→ str)

Format the hardware-based decision and effect descriptions for diagnostic logs.

measure(→ Dict[str, object])

Return CPU count, physical memory, threshold flags and the parsed override.

override(→ Optional[bool])

Parse the environment override; return None if absent or unrecognized.

total_memory_gib(→ Optional[float])

Physical memory in GiB, or None when it cannot be read.

usable_cores(→ int)

Return the CPU affinity count, falling back to os.cpu_count.

wanted(→ Tuple[bool, str])

Return the hardware-based laptop-mode decision and its explanation.

what_it_turns_down(→ Tuple[Tuple[str, str], ...])

Return the animation and backdrop-blur descriptions used in diagnostics.

Module Contents

spacr.qt.laptop_mode.apply(on: bool | None = None) → Dict[str, object][source]

Apply process-local backdrop suppression and report the decision and actions.

Parameters:

on – explicit decision; None uses wanted(), including its hardware reading and environment override.

Returns:

a mapping with on, why and changed. on is the decision; changed lists actions actually performed and may be empty.

Suppression is process-local and does not replace the stored animation preference. Disabling clears only suppression created by this module, retaining any pre-existing crash-recovery override.

spacr.qt.laptop_mode.describe() → str[source]

Format the hardware-based decision and effect descriptions for diagnostic logs.

spacr.qt.laptop_mode.measure() → Dict[str, object][source]

Return CPU count, physical memory, threshold flags and the parsed override.

spacr.qt.laptop_mode.override() → bool | None[source]

Parse the environment override; return None if absent or unrecognized.

spacr.qt.laptop_mode.total_memory_gib() → float | None[source]

Physical memory in GiB, or None when it cannot be read.

spacr.qt.laptop_mode.usable_cores() → int[source]

Return the CPU affinity count, falling back to os.cpu_count.

os.sched_getaffinity accounts for process pinning when available. If it is unavailable or fails, use the reported CPU count instead. The result is at least one; the fallback does not measure affinity limits.

spacr.qt.laptop_mode.wanted(reading: Dict[str, object] | None = None) → Tuple[bool, str][source]

Return the hardware-based laptop-mode decision and its explanation.

Returns:

(on, why). The reason is always populated, including when the decision is off. An explicit environment override takes precedence over the core-count and physical-memory threshold flags.

spacr.qt.laptop_mode.what_it_turns_down() → Tuple[Tuple[str, str], ...][source]

Return the animation and backdrop-blur descriptions used in diagnostics.

Each pair contains an effect name and its description for UI notes and logs. This function returns text; apply() performs the process-local backdrop suppression.