#!/bin/bash
# Mediainfo-Yad-UI, a yad frontend for the mediainfo CLI application to parse and display the contents of Media files.
# Concept and Testing by Glen MacArthur assisted by Google Gemini 3.

# Capture input and ensure it's an absolute path
f=$(realpath "$1")

# Verify the file exists before running
if [ ! -f "$f" ]; then
    yad --error --text="File not found: $f"
    exit 1
fi

# Run the real binary and pipe to YAD
# We use -i at the start of the bash call in your .desktop to ensure environment is loaded
/usr/bin/mediainfo "$f" | yad --text-info --wrap \
    --title="Media Info" \
    --image-on-top \
    --image=/usr/local/share/icons/custom/mediainfo-app.png \
    --text="<b>Details for:</b> ${f##*/}" \
    --text-align=center \
    --fontname="Cantarell" \
    --window-icon=/usr/local/share/icons/custom/mediainfo.png \
    --width=640 --height=500 --borders=24 \
    --button="Done:0"