diff --git a/pyproject.toml b/pyproject.toml index 65f545d..c717b91 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "glint-monitor" -version = "1.0.2" +version = "1.0.3" description = "A Modern Painter-Rendered Desktop System Monitor" readme = "README.md" requires-python = ">=3.10" diff --git a/src/core/sensors.py b/src/core/sensors.py index dcf43a2..c14e832 100644 --- a/src/core/sensors.py +++ b/src/core/sensors.py @@ -74,12 +74,17 @@ def _gpu(self) -> dict[str, float | None]: """Read NVIDIA CLI metrics, then vendor-neutral Windows counters.""" if self._nvidia_smi: try: + run_options = { + "capture_output": True, + "text": True, + "timeout": 2, + } + if platform.system() == "Windows": + run_options["creationflags"] = subprocess.CREATE_NO_WINDOW result = subprocess.run( ["nvidia-smi", "--query-gpu=utilization.gpu,temperature.gpu", "--format=csv,noheader,nounits"], - capture_output=True, check=True, - text=True, - timeout=2, + **run_options, ) usage, temperature = result.stdout.splitlines()[0].split(",", maxsplit=1) self._gpu_values = {"usage": float(usage.strip()), "temperature": float(temperature.strip())} diff --git a/tests/test_core.py b/tests/test_core.py index c37ed39..4d34d43 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -144,6 +144,26 @@ def test_nvidia_smi_path_is_resolved_once(monkeypatch): assert len(calls) == 1 +def test_nvidia_smi_suppresses_console_only_on_windows(monkeypatch): + import src.core.sensors as sensors_module + + reader = SensorReader() + reader._nvidia_smi = "nvidia-smi" + completed = Mock(stdout="40, 55\n") + run = Mock(return_value=completed) + monkeypatch.setattr(sensors_module.subprocess, "run", run) + monkeypatch.setattr(sensors_module.platform, "system", lambda: "Windows") + monkeypatch.setattr(sensors_module.subprocess, "CREATE_NO_WINDOW", 0x08000000, raising=False) + + assert reader._gpu() == {"usage": 40.0, "temperature": 55.0} + assert run.call_args.kwargs["creationflags"] == 0x08000000 + + run.reset_mock() + monkeypatch.setattr(sensors_module.platform, "system", lambda: "Linux") + assert reader._gpu() == {"usage": 40.0, "temperature": 55.0} + assert "creationflags" not in run.call_args.kwargs + + def test_get_all_skips_heavy_probes_after_stop(): import threading