View Single Post
Old 04-17-2025, 02:53 PM   #2
druss67
Connoisseur
druss67 can name that song in three notesdruss67 can name that song in three notesdruss67 can name that song in three notesdruss67 can name that song in three notesdruss67 can name that song in three notesdruss67 can name that song in three notesdruss67 can name that song in three notesdruss67 can name that song in three notesdruss67 can name that song in three notesdruss67 can name that song in three notesdruss67 can name that song in three notes
 
Posts: 79
Karma: 24492
Join Date: Jul 2013
Location: France
Device: Kindle 4, PBk Lux 2, PBk Lux 3, K Aura, K Libra H2O, K Libra2
I found a solution with the help of an AI.

Code:
#!/bin/sh

# === Variables ===
DEST_DIR="/mnt/onboard/.kobo/custom-dict"
URL="https://github.com/BoboTiG/ebook-reader-dict/releases/download/fr/dicthtml-fr-fr.zip"
ZIP_NAME="dicthtml-fr-fr.zip"
TMP_ZIP="${ZIP_NAME}.new"

# === Préparation ===
mkdir -p "$DEST_DIR"
cd "$DEST_DIR" || {
    echo "❌ Impossible d'accéder à $DEST_DIR" >&2
    exit 1
}

# Taille actuelle (0 si fichier absent)
old_size=$(stat -c%s "$ZIP_NAME" 2>/dev/null || echo 0)
echo "ℹ️  Taille actuelle du dictionnaire : ${old_size} octets"

# === Téléchargement dans un .new ===
echo "ℹ️  Téléchargement de la nouvelle version pour comparaison…"
if command -v wget >/dev/null 2>&1; then
    wget -q -O "$TMP_ZIP" "$URL" || {
        echo "❌ Erreur lors du téléchargement via wget" >&2
        exit 1
    }
elif command -v curl >/dev/null 2>&1; then
    curl -L -s -o "$TMP_ZIP" "$URL" || {
        echo "❌ Erreur lors du téléchargement via curl" >&2
        exit 1
    }
else
    echo "❌ Ni wget ni curl trouvés" >&2
    exit 1
fi

# Taille du nouveau fichier
new_size=$(stat -c%s "$TMP_ZIP" 2>/dev/null || echo 0)
echo "ℹ️  Taille récupérée : ${new_size} octets"

# === Comparaison et remplacement conditionnel ===
if [ "$new_size" -eq "$old_size" ]; then
    echo "ℹ️  Le dictionnaire est déjà à jour. Aucune action effectuée."
    rm -f "$TMP_ZIP"
else
    mv -f "$TMP_ZIP" "$ZIP_NAME"
    echo "✅ Dictionnaire mis à jour : $ZIP_NAME (${new_size} octets)."
fi

# === Notification finale ===
echo "🔔 Opération terminée."

exit 0
the command is launched from NickelMenu with this command:
Code:
menu_item :main   :MàJ Dico              :cmd_spawn      :sh /mnt/onboard/.adds/kfmon/scripts/update_dict.sh
If you want another language, update the variables.

BR
Druss67
druss67 is offline   Reply With Quote