From b71f0a667624555822a3873c19f3c19edfbbb6d0 Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Fri, 29 Sep 2023 15:22:23 +0200 Subject: [PATCH 1/2] cosmic-toplevel: Also match by StartupWMClass --- plugins/src/cosmic_toplevel/mod.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/plugins/src/cosmic_toplevel/mod.rs b/plugins/src/cosmic_toplevel/mod.rs index c7ca893..ddad515 100644 --- a/plugins/src/cosmic_toplevel/mod.rs +++ b/plugins/src/cosmic_toplevel/mod.rs @@ -16,7 +16,7 @@ use pop_launcher::{ Request, }; use std::borrow::Cow; -use std::{ffi::OsString, fs, path::PathBuf}; +use std::{fs, path::PathBuf}; use tokio::io::{AsyncWrite, AsyncWriteExt}; use self::toplevel_handler::{toplevel_handler, ToplevelAction, ToplevelEvent}; @@ -170,18 +170,18 @@ impl App { let mut icon_name = Cow::Borrowed("application-x-executable"); for (_, path) in &self.desktop_entries { - if let Some(name) = path.file_stem() { - let app_id: OsString = item.1.app_id.clone().into(); - if app_id == name { - if let Ok(data) = fs::read_to_string(path) { - if let Ok(entry) = fde::DesktopEntry::decode(path, &data) { - if let Some(icon) = entry.icon() { - icon_name = Cow::Owned(icon.to_owned()); - } + if let Ok(data) = fs::read_to_string(&path) { + if let Ok(entry) = fde::DesktopEntry::decode(&path, &data) { + if item.1.app_id == entry.appid + || entry + .startup_wm_class() + .is_some_and(|class| class == item.1.app_id) + { + if let Some(icon) = entry.icon() { + icon_name = Cow::Owned(icon.to_owned()); } + break; } - - break; } } } From ddf4936d25ba8e8263d893180f9281eacb78249d Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Fri, 29 Sep 2023 15:22:49 +0200 Subject: [PATCH 2/2] desktop-entries: Icon fallback --- plugins/src/desktop_entries/mod.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/src/desktop_entries/mod.rs b/plugins/src/desktop_entries/mod.rs index 9524d5c..9fcc76a 100644 --- a/plugins/src/desktop_entries/mod.rs +++ b/plugins/src/desktop_entries/mod.rs @@ -161,7 +161,12 @@ impl App { keywords: entry.keywords().map(|keywords| { keywords.split(';').map(String::from).collect() }), - icon: entry.icon().map(|x| x.to_owned()), + icon: Some( + entry + .icon() + .map(|x| x.to_owned()) + .unwrap_or_else(|| "application-x-executable".to_string()), + ), exec: exec.to_owned(), path: path.clone(), prefers_non_default_gpu: entry.prefers_non_default_gpu(),