From 86ba767b236dea98d604ec4407774dee6c2cf892 Mon Sep 17 00:00:00 2001 From: GroobleDierne Date: Wed, 11 Sep 2024 12:57:16 +0200 Subject: [PATCH 1/2] Shown empty dropdown menu when no app uses dGPU --- cosmic-applet-battery/src/dgpu.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cosmic-applet-battery/src/dgpu.rs b/cosmic-applet-battery/src/dgpu.rs index 11b6bb50..3f017093 100644 --- a/cosmic-applet-battery/src/dgpu.rs +++ b/cosmic-applet-battery/src/dgpu.rs @@ -222,7 +222,10 @@ 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(); From bc782fb9201c236bb9cd40c3c5f445b88ed536de Mon Sep 17 00:00:00 2001 From: GroobleDierne Date: Wed, 11 Sep 2024 13:09:37 +0200 Subject: [PATCH 2/2] chore: format --- cosmic-applet-battery/src/dgpu.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cosmic-applet-battery/src/dgpu.rs b/cosmic-applet-battery/src/dgpu.rs index 3f017093..ab807131 100644 --- a/cosmic-applet-battery/src/dgpu.rs +++ b/cosmic-applet-battery/src/dgpu.rs @@ -222,7 +222,8 @@ impl Gpu { Some( smi_output .lines() - .filter(|line| { // smi shows an empty line filled with - when no app is running + .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('#') })