id: com.pena.app
runtime: org.gnome.Platform
runtime-version: '48'
sdk: org.gnome.Sdk
command: pena

finish-args:
  # Affichage
  - --socket=wayland
  - --socket=fallback-x11
  - --device=dri
  - --share=ipc
  # Lecture des fichiers Markdown ouverts par l'utilisateur
  - --filesystem=home

modules:
  - name: pena
    buildsystem: simple
    sources:
      - type: file
        path: pena.deb
      - type: file
        path: com.pena.app.metainfo.xml
      - type: file
        path: icon.png
    build-commands:
      - |
        set -eux
        # Extraction du .deb produit par `cargo tauri build`
        ar -x pena.deb
        tar -xf data.tar.gz

        # Binaire principal -> /app/bin/pena (correspond à `command:`)
        bin="$(find usr/bin -maxdepth 1 -type f | head -n1)"
        install -Dm755 "$bin" /app/bin/pena

        # Fichier .desktop : renommé en <app-id>.desktop (exigence Flatpak)
        desktop="$(find usr/share/applications -name '*.desktop' | head -n1)"
        install -Dm644 "$desktop" /app/share/applications/com.pena.app.desktop
        sed -i \
          -e 's/^Exec=.*/Exec=pena/' \
          -e 's/^Icon=.*/Icon=com.pena.app/' \
          /app/share/applications/com.pena.app.desktop

        # Icône (128x128) fournie séparément à côté du manifeste.
        install -Dm644 icon.png /app/share/icons/hicolor/128x128/apps/com.pena.app.png

        # Métadonnées AppStream
        install -Dm644 com.pena.app.metainfo.xml /app/share/metainfo/com.pena.app.metainfo.xml
