SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
AppImage: refresh the icon cache so the taskbar shows the mark (#10673) (#10858)
SilentWolf752b08e0c6a758
diff --git a/packaging/linux/AppRun b/packaging/linux/AppRunindex 9d27aeee7f..36400a9220 100755--- a/packaging/linux/AppRun+++ b/packaging/linux/AppRun@@ -7,12 +7,14 @@# An AppImage installs nothing, so every AppImage run would otherwise show the# generic "Wayland" icon. Best-effort desktop integration: on first run# (and whenever the AppImage's path changes) install the .desktop entry and the-# hicolor icons into $XDG_DATA_HOME, then launch. Every failure here must leave-# the launch untouched. Opt out with SOLIDCRAFT_NO_DESKTOP_INTEGRATION=1 (the pre-rename-# SOLVECRAFT_NO_DESKTOP_INTEGRATION still works: compatibility shim, docs/compatibility.md),-# or for good with an empty file $XDG_DATA_HOME/solidcraft/no-desktop-integration. Nothing is-# installed either when appimaged (go-appimage) already made an entry for this AppImage, or when-# a launcher that manages AppImages (Gear Lever, AppImageLauncher) started it: it sets+# hicolor icons into $XDG_DATA_HOME, refresh the icon cache, point Icon= at the+# installed PNG (panels that skip the theme cache still show the mark; #10673),+# then launch. Every failure here must leave the launch untouched. Opt out with+# SOLIDCRAFT_NO_DESKTOP_INTEGRATION=1 (the pre-rename SOLVECRAFT_NO_DESKTOP_INTEGRATION+# still works: compatibility shim, docs/compatibility.md), or for good with an empty+# file $XDG_DATA_HOME/solidcraft/no-desktop-integration. Nothing is installed either+# when appimaged (go-appimage) already made an entry for this AppImage, or when a+# launcher that manages AppImages (Gear Lever, AppImageLauncher) started it: it sets# DESKTOPINTEGRATION and owns the menu entry.## The same step puts `solidcraft-cli` on PATH: a small wrapper script in ~/.local/bin that starts this@@ -98,12 +100,37 @@ integrate() {return 0done- # Rewrite Exec to this AppImage (the binary is not on the host PATH) and drop- # TryExec, which would hide the entry; everything else is shipped as packaged.+ # Icons first: the desktop entry's Icon= points at the installed 256×256 PNG so panels+ # that skip the theme cache still show the mark (#10673: Mint Cinnamon AppImage taskbar).+ src_icons="$APPDIR/usr/share/icons/hicolor"+ icons="$data/icons/hicolor"+ if [ -d "$src_icons" ]; then+ (cd "$src_icons" && find . -type f) | while IFS= read -r rel; do+ mkdir -p "$icons/$(dirname "$rel")" 2>/dev/null || continue+ if ! cmp -s "$src_icons/$rel" "$icons/$rel"; then+ cp "$src_icons/$rel" "$icons/$rel" 2>/dev/null || true+ fi+ done+ if command -v gtk-update-icon-cache >/dev/null 2>&1; then+ gtk-update-icon-cache -q -t -f "$icons" 2>/dev/null || true+ elif command -v update-icon-caches >/dev/null 2>&1; then+ update-icon-caches "$icons" 2>/dev/null || true+ fi+ fi++ # Rewrite Exec to this AppImage (the binary is not on the host PATH), drop TryExec+ # (which would hide the entry), and point Icon at the installed PNG when we have one.mkdir -p "$apps" 2>/dev/null || return 0tmp="$apps/.$DESK_ID.tmp.$$"esc="$(printf '%s' "$appimage" | sed 's/[\\&|]/\\&/g')"- if sed -e "s|^Exec=.*|Exec=\"$esc\" %F|" -e '/^TryExec=/d' "$src_desktop" 2>/dev/null >"$tmp"; then+ icon_png="$icons/256x256/apps/$DESK_ID.png"+ if [ -f "$icon_png" ]; then+ icon_esc="$(printf '%s' "$icon_png" | sed 's/[\\&|]/\\&/g')"+ icon_sed="s|^Icon=.*|Icon=$icon_esc|"+ else+ icon_sed='s|^Icon=.*|Icon='"$DESK_ID"'|'+ fi+ if sed -e "s|^Exec=.*|Exec=\"$esc\" %F|" -e '/^TryExec=/d' -e "$icon_sed" "$src_desktop" 2>/dev/null >"$tmp"; thenif cmp -s "$tmp" "$apps/$DESK_ID.desktop"; thenrm -f "$tmp"else@@ -127,17 +154,6 @@ integrate() {command -v update-desktop-database >/dev/null 2>&1 && update-desktop-database "$apps" >/dev/null 2>&1fidone-- # Icons: per-file compare so an unchanged install costs a handful of cmp calls.- src_icons="$APPDIR/usr/share/icons/hicolor"- [ -d "$src_icons" ] || return 0- icons="$data/icons/hicolor"- (cd "$src_icons" && find . -type f) | while IFS= read -r rel; do- mkdir -p "$icons/$(dirname "$rel")" 2>/dev/null || continue- if ! cmp -s "$src_icons/$rel" "$icons/$rel"; then- cp "$src_icons/$rel" "$icons/$rel" 2>/dev/null || true- fi- done}# Started through the wrapper `integrate` installs: the command-line tool, with no integration.diff --git a/packaging/tests/apprun_test.py b/packaging/tests/apprun_test.pyindex 999936dc4e..a7703f464c 100644--- a/packaging/tests/apprun_test.py+++ b/packaging/tests/apprun_test.py@@ -82,6 +82,21 @@ class AppRunCli(unittest.TestCase):self.run_apprun(SOLIDCRAFT_NO_DESKTOP_INTEGRATION="1")self.assertFalse(self.wrapper.exists())+ def test_desktop_entry_icon_is_an_absolute_png_path(self):+ # Ship a hicolor mark so AppRun can copy it and point Icon= at the install (#10673).+ src = self.appdir / "usr/share/icons/hicolor/256x256/apps"+ src.mkdir(parents=True)+ (src / "io.tangencylabs.solidcraft.png").write_bytes(b"\x89PNG\r\n\x1a\n")+ (self.appdir / "usr/share/applications/io.tangencylabs.solidcraft.desktop").write_text(+ "[Desktop Entry]\nExec=solidcraft\nIcon=io.tangencylabs.solidcraft\n"+ )+ self.run_apprun()+ desk = (self.home / ".local/share/applications/io.tangencylabs.solidcraft.desktop").read_text()+ installed = self.home / ".local/share/icons/hicolor/256x256/apps/io.tangencylabs.solidcraft.png"+ self.assertTrue(installed.is_file())+ self.assertIn(f"Icon={installed}", desk)+ self.assertNotIn("Icon=io.tangencylabs.solidcraft\n", desk)+if __name__ == "__main__":unittest.main()