Extract and apply StartupWMClass for proper taskbar icons

This commit is contained in:
2026-02-28 00:02:44 +02:00
parent a61f976546
commit fe353e1c5d
4 changed files with 39 additions and 0 deletions

View File

@@ -133,6 +133,11 @@ pub fn run_background_analysis(id: i64, path: PathBuf, appimage_type: AppImageTy
Some(meta.screenshot_urls.join("\n"))
};
// Store StartupWMClass
if let Some(ref wm_class) = meta.startup_wm_class {
db.set_startup_wm_class(id, Some(wm_class)).ok();
}
if let Err(e) = db.update_appstream_metadata(
id,
meta.appstream_id.as_deref(),

View File

@@ -1754,6 +1754,14 @@ impl Database {
Ok(())
}
pub fn set_startup_wm_class(&self, id: i64, wm_class: Option<&str>) -> SqlResult<()> {
self.conn.execute(
"UPDATE appimages SET startup_wm_class = ?2 WHERE id = ?1",
params![id, wm_class],
)?;
Ok(())
}
// --- Launch statistics ---
pub fn get_top_launched(&self, limit: i32) -> SqlResult<Vec<(String, u64)>> {

View File

@@ -61,6 +61,7 @@ pub struct AppImageMetadata {
pub desktop_actions: Vec<String>,
pub has_signature: bool,
pub screenshot_urls: Vec<String>,
pub startup_wm_class: Option<String>,
}
#[derive(Debug, Default)]
@@ -76,6 +77,7 @@ struct DesktopEntryFields {
mime_types: Vec<String>,
terminal: bool,
x_appimage_name: Option<String>,
startup_wm_class: Option<String>,
actions: Vec<String>,
}
@@ -367,6 +369,7 @@ fn parse_desktop_entry(content: &str) -> DesktopEntryFields {
}
"Terminal" => fields.terminal = value == "true",
"X-AppImage-Name" => fields.x_appimage_name = Some(value.to_string()),
"StartupWMClass" => fields.startup_wm_class = Some(value.to_string()),
"Actions" => {
fields.actions = value
.split(';')
@@ -814,6 +817,7 @@ pub fn inspect_appimage(
.as_ref()
.map(|a| a.screenshot_urls.clone())
.unwrap_or_default(),
startup_wm_class: fields.startup_wm_class,
})
}