SVG-Icons statt ICNS, Popup-Höhe an Monitor begrenzt, GNOME-Shell-Extension für Popup-Positionierung, Bundle-Targets explizit
This commit is contained in:
+6
-29
@@ -1086,8 +1086,7 @@ fn sync_all_desktops(paths: &Paths) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Icon eines Projekts als PNG-data-URL für die Übersicht; ICNS wird per
|
||||
/// sips nach PNG konvertiert, weil der Browser ICNS nicht rendert.
|
||||
/// Icon eines Projekts als data-URL für die Übersicht (PNG oder SVG).
|
||||
#[tauri::command]
|
||||
fn project_icon(project: String) -> Result<Option<String>, String> {
|
||||
use base64::{engine::general_purpose::STANDARD, Engine};
|
||||
@@ -1096,34 +1095,12 @@ fn project_icon(project: String) -> Result<Option<String>, String> {
|
||||
return Ok(None);
|
||||
};
|
||||
let path = resolve_icon_path(&paths, &icon);
|
||||
let is_icns = path
|
||||
.extension()
|
||||
.and_then(|e| e.to_str())
|
||||
.is_some_and(|e| e.eq_ignore_ascii_case("icns"));
|
||||
let png = if is_icns {
|
||||
icns_to_png_bytes(&path, &project)?
|
||||
} else {
|
||||
fs::read(&path).map_err(|e| format!("{}: {e}", path.display()))?
|
||||
let mime = match path.extension().and_then(|e| e.to_str()) {
|
||||
Some(e) if e.eq_ignore_ascii_case("svg") => "image/svg+xml",
|
||||
_ => "image/png",
|
||||
};
|
||||
Ok(Some(format!("data:image/png;base64,{}", STANDARD.encode(png))))
|
||||
}
|
||||
|
||||
/// ICNS → PNG-Bytes via sips (nur macOS; Linux hat kein ICNS).
|
||||
fn icns_to_png_bytes(src: &std::path::Path, project: &str) -> Result<Vec<u8>, String> {
|
||||
let tmp = std::env::temp_dir().join(format!("ai-control-tray-icon-{project}.png"));
|
||||
let out = Command::new("sips")
|
||||
.args(["-s", "format", "png"])
|
||||
.arg(src)
|
||||
.arg("--out")
|
||||
.arg(&tmp)
|
||||
.output()
|
||||
.map_err(|e| format!("sips: {e}"))?;
|
||||
if !out.status.success() {
|
||||
return Err(format!("sips: {}", String::from_utf8_lossy(&out.stderr)));
|
||||
}
|
||||
let bytes = fs::read(&tmp).map_err(|e| format!("{}: {e}", tmp.display()))?;
|
||||
let _ = fs::remove_file(&tmp);
|
||||
Ok(bytes)
|
||||
let bytes = fs::read(&path).map_err(|e| format!("{}: {e}", path.display()))?;
|
||||
Ok(Some(format!("data:{mime};base64,{}", STANDARD.encode(bytes))))
|
||||
}
|
||||
|
||||
/// Terminal-Einstellungen eines Projekts, für den Terminal-Prozess.
|
||||
|
||||
Reference in New Issue
Block a user