From 3670f124fb51ff730c470398014a38ee166e2dbb Mon Sep 17 00:00:00 2001 From: Grooble Date: Tue, 24 Sep 2024 15:52:53 +0200 Subject: [PATCH] fix: show empty dropdown menu when no app uses dGPU --- cosmic-applet-battery/src/dgpu.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cosmic-applet-battery/src/dgpu.rs b/cosmic-applet-battery/src/dgpu.rs index 11b6bb50..ab807131 100644 --- a/cosmic-applet-battery/src/dgpu.rs +++ b/cosmic-applet-battery/src/dgpu.rs @@ -222,7 +222,11 @@ impl Gpu { Some( smi_output .lines() - .filter(|line| !line.starts_with('#')) + .filter(|line| { + // smi shows an empty line filled with - when no app is running + let components = line.split_whitespace().collect::>(); + components[1].trim().ne("-") && !line.starts_with('#') + }) .map(|line| { let components = line.split_whitespace().collect::>(); let pid = components[1].trim();