Skip to content

Commit b1f6002

Browse files
authored
Merge pull request #195 from pop-os/fix-wmclass
cosmic-toplevel: Also match by StartupWMClass
2 parents 0febac5 + ddf4936 commit b1f6002

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

plugins/src/cosmic_toplevel/mod.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use pop_launcher::{
1616
Request,
1717
};
1818
use std::borrow::Cow;
19-
use std::{ffi::OsString, fs, path::PathBuf};
19+
use std::{fs, path::PathBuf};
2020
use tokio::io::{AsyncWrite, AsyncWriteExt};
2121

2222
use self::toplevel_handler::{toplevel_handler, ToplevelAction, ToplevelEvent};
@@ -170,18 +170,18 @@ impl<W: AsyncWrite + Unpin> App<W> {
170170
let mut icon_name = Cow::Borrowed("application-x-executable");
171171

172172
for (_, path) in &self.desktop_entries {
173-
if let Some(name) = path.file_stem() {
174-
let app_id: OsString = item.1.app_id.clone().into();
175-
if app_id == name {
176-
if let Ok(data) = fs::read_to_string(path) {
177-
if let Ok(entry) = fde::DesktopEntry::decode(path, &data) {
178-
if let Some(icon) = entry.icon() {
179-
icon_name = Cow::Owned(icon.to_owned());
180-
}
173+
if let Ok(data) = fs::read_to_string(&path) {
174+
if let Ok(entry) = fde::DesktopEntry::decode(&path, &data) {
175+
if item.1.app_id == entry.appid
176+
|| entry
177+
.startup_wm_class()
178+
.is_some_and(|class| class == item.1.app_id)
179+
{
180+
if let Some(icon) = entry.icon() {
181+
icon_name = Cow::Owned(icon.to_owned());
181182
}
183+
break;
182184
}
183-
184-
break;
185185
}
186186
}
187187
}

plugins/src/desktop_entries/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,12 @@ impl<W: AsyncWrite + Unpin> App<W> {
161161
keywords: entry.keywords().map(|keywords| {
162162
keywords.split(';').map(String::from).collect()
163163
}),
164-
icon: entry.icon().map(|x| x.to_owned()),
164+
icon: Some(
165+
entry
166+
.icon()
167+
.map(|x| x.to_owned())
168+
.unwrap_or_else(|| "application-x-executable".to_string()),
169+
),
165170
exec: exec.to_owned(),
166171
path: path.clone(),
167172
prefers_non_default_gpu: entry.prefers_non_default_gpu(),

0 commit comments

Comments
 (0)