Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix: win icon (#1257)

tribhuwana59e0edbe11e
diff --git a/screenpipe-app-tauri/src-tauri/Cargo.toml b/screenpipe-app-tauri/src-tauri/Cargo.toml
index fabb4fa94..f667dc43b 100644
--- a/screenpipe-app-tauri/src-tauri/Cargo.toml
+++ b/screenpipe-app-tauri/src-tauri/Cargo.toml
@@ -109,6 +109,7 @@ tauri-nspanel = { git = "https://github.com/ahkohd/tauri-nspanel", branch = "v2"
[target.'cfg(target_os = "windows")'.dependencies]
winreg = "0.52.0"
lazy_static = "1.5.0"
+image = "0.25.5"
windows-icons = { git = "https://github.com/tribhuwan-kumar/windows-icons.git" }
[target.'cfg(target_os = "linux")'.dependencies]
diff --git a/screenpipe-app-tauri/src-tauri/src/icons.rs b/screenpipe-app-tauri/src-tauri/src/icons.rs
index 06d8708e5..c87da82f2 100644
--- a/screenpipe-app-tauri/src-tauri/src/icons.rs
+++ b/screenpipe-app-tauri/src-tauri/src/icons.rs
@@ -82,7 +82,10 @@ pub async fn get_app_icon(
app_name: &str,
app_path: Option<String>,
) -> Result<Option<AppIcon>, String> {
- use windows_icons::get_icon_image_by_path;
+ use windows_icons::get_icon_by_path;
+ use std::io::Cursor;
+ use image::{ImageEncoder, ExtendedColorType};
+ use image::codecs::png::PngEncoder;
async fn find_exe_path(app_name: &str) -> Option<String> {
if let Some(path) = get_exe_by_reg_key(app_name) {
@@ -104,10 +107,21 @@ pub async fn get_app_icon(
.ok_or_else(|| "app_path is None and could not find executable path".to_string())?,
};
- let data = get_icon_image_by_path(&path)
- .await
- .map_err(|e| e.to_string())?;
-
+ let image_buffer = async {
+ get_icon_by_path(&path)
+ }.await.map_err(|e| e.to_string())?;
+
+ let mut data = Vec::new();
+ {
+ let mut cursor = Cursor::new(&mut data);
+ let encoder = PngEncoder::new(&mut cursor);
+ encoder.write_image(
+ &image_buffer,
+ image_buffer.width(),
+ image_buffer.height(),
+ ExtendedColorType::Rgba8,
+ ).map_err(|e| e.to_string())?;
+ }
Ok(Some(AppIcon {
data,
path: Some(path),