fix(linux): preserve AppImage executable bit via .tar.gz and auto-integrate Ubuntu icons

Browsers strip POSIX executable permissions (+x) from raw .AppImage files
downloaded directly over HTTP, leaving the downloaded binary non-executable in
Ubuntu Files (Nautilus). Additionally, Ubuntu displays a generic cog icon for
standalone AppImages in both Nautilus and the Ubuntu Dock on Wayland unless
desktop metadata, high-DPI icons, and GVfs custom icon attributes are
registered.

- Wrap `Asteria-<arch>.AppImage` (`0755`) in a `.AppImage.tar.gz` archive in
  `package-linux.sh` and point CI wiki links to the archive so extracting the
  download preserves executable permissions out of the box.
- Copy `.DirIcon` as a regular PNG file rather than a symlink so SquashFS icon
  extractors that do not follow symlinks receive valid image bytes.
- Add non-blocking first-launch integration in `AppRun` to install `hicolor`
  icons and `asteria-qt.desktop` (`StartupWMClass=asteria-qt`) under
  `XDG_DATA_HOME` and apply `metadata::custom-icon` on `$APPIMAGE` via `gio`
  for Nautilus.
- Embed 128x128, 256x256, and 512x512 icons in Qt resources and register them
  with `QApplication::setWindowIcon()`.
This commit is contained in:
Agel committed 2026-11-19 14:49:54 +01:00
1 parent 2636b7cf51
commit 832e24c6f7
7 files changed
+63 -7

No files matched your search

+44 -1
View File
@@ -130,7 +130,7 @@ def setup_appdir_metadata(appdir):
dir_icon = os.path.join(appdir, ".DirIcon")
if os.path.lexists(dir_icon):
os.remove(dir_icon)
os.symlink("asteria-qt.png", dir_icon)
shutil.copy2(icon_src, dir_icon)
apprun_path = os.path.join(appdir, "AppRun")
with open(apprun_path, "w", encoding="utf-8") as f:
@@ -141,6 +141,49 @@ def setup_appdir_metadata(appdir):
'export QT_PLUGIN_PATH="$HERE/usr/plugins"\n'
'export QML2_IMPORT_PATH="$HERE/usr/qml"\n'
'export QML_IMPORT_PATH="$HERE/usr/qml"\n'
"\n"
'# Auto-integrate desktop icon & Nautilus file icon when running as an AppImage\n'
'if [ -n "${APPIMAGE:-}" ] && [ -f "$APPIMAGE" ] && [ -n "${HOME:-}" ]; then\n'
" (\n"
' DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"\n'
" for sz in 16 32 48 64 128 256 512; do\n"
' SRC_ICON="$HERE/usr/share/icons/hicolor/${sz}x${sz}/apps/asteria-qt.png"\n'
' DST_DIR="$DATA_HOME/icons/hicolor/${sz}x${sz}/apps"\n'
' if [ -f "$SRC_ICON" ]; then\n'
' mkdir -p "$DST_DIR"\n'
' cp -f "$SRC_ICON" "$DST_DIR/asteria-qt.png"\n'
" fi\n"
" done\n"
' ICON_256="$DATA_HOME/icons/hicolor/256x256/apps/asteria-qt.png"\n'
' APPS_DIR="$DATA_HOME/applications"\n'
' mkdir -p "$APPS_DIR"\n'
' ESCAPED_APPIMAGE=$(printf "%s" "$APPIMAGE" | sed \'s/"/\\\\"/g\')\n'
' cat <<EOF > "$APPS_DIR/asteria-qt.desktop"\n'
"[Desktop Entry]\n"
"Type=Application\n"
"Name=Asteria\n"
"Comment=Cross-platform book reader\n"
'Exec="$ESCAPED_APPIMAGE" %f\n'
"TryExec=$APPIMAGE\n"
"Icon=$ICON_256\n"
"StartupWMClass=asteria-qt\n"
"Categories=Office;Viewer;\n"
"MimeType=application/epub+zip;application/x-fictionbook+xml;application/vnd.comicbook+zip;application/vnd.comicbook-rar;text/plain;\n"
"EOF\n"
' chmod 755 "$APPS_DIR/asteria-qt.desktop"\n'
" if command -v gio >/dev/null 2>&1; then\n"
' gio set "$APPIMAGE" metadata::custom-icon "file://$ICON_256" 2>/dev/null || true\n'
' gio set "$APPS_DIR/asteria-qt.desktop" metadata::trusted true 2>/dev/null || true\n'
" fi\n"
" if command -v update-desktop-database >/dev/null 2>&1; then\n"
' update-desktop-database "$APPS_DIR" 2>/dev/null || true\n'
" fi\n"
" if command -v gtk-update-icon-cache >/dev/null 2>&1; then\n"
' gtk-update-icon-cache -f -t "$DATA_HOME/icons/hicolor" 2>/dev/null || true\n'
" fi\n"
" ) >/dev/null 2>&1 &\n"
"fi\n"
"\n"
'exec "$HERE/usr/bin/asteria-qt" "$@"\n'
)
os.chmod(apprun_path, 0o755)