#!/bin/sh

set -eu

command=$1
shift

case "${command}" in
    configure)
	upstream_dir=$1

	ln -fns "${upstream_dir}" /opt/openshot
        cat <<EOF > /usr/share/applications/openshot-appimage.desktop
[Desktop Entry]
Name=Openshot
Exec=/opt/openshot/openshot.AppImage
Type=Application
Terminal=false
Icon=glade
StartupNotify=true
Categories=Education;
EOF
	;;
    unconfigure)
	rm -f /opt/openshot \
              /usr/share/applications/openshot-appimage.desktop
	;;
    unpack)
	upstream_pack=$1
	upstream_dir=$2

        cp "${upstream_pack}" "${upstream_dir}/openshot.AppImage"
        chmod 755 "${upstream_dir}/openshot.AppImage"
	;;
    *)
	;;
esac
