diff --git a/packaging/windows/main.wxs b/packaging/windows/main.wxs index 9183c8bd8..b1878edaf 100644 --- a/packaging/windows/main.wxs +++ b/packaging/windows/main.wxs @@ -112,13 +112,48 @@ next association query without a forced refresh. --> + + + + + + + Value='Open CAD Studio' /> Result<(), String> { + static LOGO_SVG: &[u8] = include_bytes!("../../assets/logo.svg"); + + let icon_dir = data_home()?.join("icons/hicolor/scalable/apps"); + let icon_path = icon_dir.join(format!("{APP_ID}.svg")); + + // Skip write when the on-disk file is already identical. + if std::fs::read(&icon_path).ok().as_deref() == Some(LOGO_SVG) { + return Ok(()); + } + + std::fs::create_dir_all(&icon_dir).map_err(|e| e.to_string())?; + std::fs::write(&icon_path, LOGO_SVG).map_err(|e| e.to_string())?; + + // Refresh the icon cache so desktop environments pick up the new file. + let hicolor = data_home() + .map(|d| d.join("icons/hicolor")) + .unwrap_or_default(); + let _ = std::process::Command::new("gtk-update-icon-cache") + .args(["--force", "--quiet", &hicolor.to_string_lossy()]) + .status(); + Ok(()) + } + fn data_home() -> Result { std::env::var_os("XDG_DATA_HOME") .map(PathBuf::from)