#!/usr/bin/python
# coding: utf-8
# version 19.1.22 
import os
from sys import exit
com="org.blender.Blender"
nom="Blender"
nm="blender"
cat="AudioVideo"
# verif flatpak
rep=os.system("flatpak install --help | grep yes")
if not rep==0:
    os.system('hermes --msg "Le flatpak ne peut pas être installé sur votre machine.\nVeuillez contacter Elicthus sur www.elicthus.com\n(élément manquant : flatpak>0.9)"')
    exit("arret")
# confi depot
os.system("flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo")
# install
os.system("flatpak -y install flathub "+com)
# lanceur
os.system("echo '[Desktop Entry]' > /usr/share/applications/"+nm+"-flatpak.desktop")
os.system("echo 'Name="+nom+"' >> /usr/share/applications/"+nm+"-flatpak.desktop")
os.system("echo 'Icon=/var/lib/flatpak/app/"+com+"/current/active/export/share/icons/hicolor/48x48/apps/"+com+".png' >> /usr/share/applications/"+nm+"-flatpak.desktop")
os.system("echo 'Exec=flatpak run "+com+"' >> /usr/share/applications/"+nm+"-flatpak.desktop")
os.system("echo 'Type=Application' >> /usr/share/applications/"+nm+"-flatpak.desktop")
os.system("echo 'Categories="+cat+";' >> /usr/share/applications/"+nm+"-flatpak.desktop")
# maj-flatpak
if not os.path.isdir("/usr/share/elicthus/conf"):
    os.system("mkdir /usr/share/elicthus/conf")
os.system("echo '"+com+"' >> /usr/share/elicthus/conf/maj-flatpak")

