From 34ed92a64782bdec8befcdbdb5ee79dec2c83582 Mon Sep 17 00:00:00 2001 From: s Date: Tue, 30 Jun 2026 11:55:04 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20chemin=20stable=20pour=20AppImage,=20des?= =?UTF-8?q?ktop=20entry=20permanent=20apr=C3=A8s=20install=20initiale?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install-desktop-entry.sh | 41 ++++++++++++++++++++++++---------------- main.js | 12 +++++++++--- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/install-desktop-entry.sh b/install-desktop-entry.sh index 3743cc8..a239c97 100755 --- a/install-desktop-entry.sh +++ b/install-desktop-entry.sh @@ -1,37 +1,46 @@ #!/usr/bin/env bash -# Installe (ou met à jour) l'entrée de menu "Farm Tracker" pointant vers l'AppImage déjà construit. -set -e +# Installation initiale de Farm Tracker (AppImage + entrée de menu). +# À lancer une seule fois. Les mises à jour suivantes sont automatiques. +set -euo pipefail -APPDIR="/home/shamiiow/GitHub/farm-tracker-app/dist" -APPIMAGE=$(ls "$APPDIR"/*.AppImage 2>/dev/null | head -n1) +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +DIST_DIR="$SCRIPT_DIR/dist" -if [ -z "$APPIMAGE" ]; then - echo "Aucun fichier .AppImage trouvé dans : $APPDIR" - echo "Lance d'abord (depuis le dossier du projet) : npm run dist" +# Trouve l'AppImage dans dist/ +APPIMAGE_SRC=$(ls "$DIST_DIR"/*.AppImage 2>/dev/null | head -n1) +if [ -z "$APPIMAGE_SRC" ]; then + echo "Aucun .AppImage trouvé dans dist/. Lance d'abord : npm run dist" exit 1 fi -chmod +x "$APPIMAGE" +# Chemin stable — indépendant de la version +INSTALL_DIR="$HOME/.local/bin" +STABLE_PATH="$INSTALL_DIR/farm-tracker.AppImage" +mkdir -p "$INSTALL_DIR" +cp "$APPIMAGE_SRC" "$STABLE_PATH" +chmod +x "$STABLE_PATH" + +# Entrée de menu DESKTOP_DIR="$HOME/.local/share/applications" mkdir -p "$DESKTOP_DIR" -DESKTOP_FILE="$DESKTOP_DIR/farm-tracker.desktop" -cat > "$DESKTOP_FILE" << INNEREOF +cat > "$DESKTOP_DIR/farm-tracker.desktop" << EOF [Desktop Entry] Type=Application Name=Farm Tracker Comment=Suivi de loot Minecraft en direct -Exec="$APPIMAGE" %U +Exec="$STABLE_PATH" %U Icon=applications-games Terminal=false Categories=Game;Utility; StartupWMClass=farm-tracker -INNEREOF +EOF -chmod +x "$DESKTOP_FILE" +chmod +x "$DESKTOP_DIR/farm-tracker.desktop" update-desktop-database "$DESKTOP_DIR" >/dev/null 2>&1 || true -echo "Entrée installée : $DESKTOP_FILE" -echo "AppImage détecté : $APPIMAGE" -echo "Cherche \"Farm Tracker\" dans ton menu d'applications (déconnexion/reconnexion parfois nécessaire selon le bureau)." +echo "Installé dans : $STABLE_PATH" +echo "Entrée de menu : $DESKTOP_DIR/farm-tracker.desktop" +echo "" +echo "Les prochaines mises à jour s'installeront automatiquement sans rien retoucher." diff --git a/main.js b/main.js index d891b29..ef6550b 100644 --- a/main.js +++ b/main.js @@ -153,9 +153,15 @@ async function downloadAndInstall(downloadUrl, version) { sendUpdateProgress(100, 'installing'); if (process.platform === 'linux') { fs.chmodSync(tmpPath, 0o755); - const current = process.env.APPIMAGE; - if (current) { fs.copyFileSync(tmpPath, current); fs.unlinkSync(tmpPath); app.relaunch(); } - else app.relaunch({ execPath: tmpPath }); + const stablePath = path.join(require('os').homedir(), '.local', 'bin', 'farm-tracker.AppImage'); + const target = fs.existsSync(stablePath) ? stablePath : process.env.APPIMAGE; + if (target) { + fs.copyFileSync(tmpPath, target); + fs.unlinkSync(tmpPath); + app.relaunch({ execPath: target }); + } else { + app.relaunch({ execPath: tmpPath }); + } app.exit(0); } else if (process.platform === 'win32') { const { spawn } = require('child_process');