#!/bin/bash

DIRECTORY="$(dirname "$(dirname "$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )")")"

function error {
  echo -e "\\e[91m$1\\e[39m"
  exit 1
}

rm -rf ~/eDEX-UI-RPi &>/dev/null
git clone https://github.com/Botspot/eDEX-UI-RPi || error 'Failed to clone repository!'
chmod +x ./'eDEX-UI-RPi/eDEX-UI_Linux_armv7l_2.2.2.AppImage' ./'eDEX-UI-RPi/eDEX-UI Linux (armv7l)_3.0.0.AppImage' || error 'Failed to mark as executable!'

echo "[Desktop Entry]
Name=eDEX-UI 2.2.2
Comment=eDEX-UI sci-fi interface
Exec="\""$HOME/eDEX-UI-RPi/eDEX-UI_Linux_armv7l_2.2.2.AppImage"\"" %U
Terminal=false
Type=Application
Icon=$(dirname "$0")/icon-64.png
StartupWMClass=eDEX-UI
X-AppImage-Version=2.2.2
Categories=System;
X-AppImage-BuildId=1jnzBrm5tFNCUYZfKMXmYF0U2Ky
X-Desktop-File-Install-Version=0.23
X-AppImage-Comment=Generated by /tmp/.mount_eDEX-UDQYwse/AppRun" > ~/.local/share/applications/appimagekit-edex-ui.desktop

echo "[Desktop Entry]
Name=eDEX-UI 3.0.0
Comment=eDEX-UI sci-fi interface
Exec="\""$HOME/eDEX-UI-RPi/eDEX-UI Linux (armv7l)_3.0.0.AppImage"\"" %U
Terminal=false
Type=Application
Icon=$(dirname "$0")/icon-64.png
StartupWMClass=eDEX-UI
X-AppImage-Version=3.0.0
Categories=System;" > ~/.local/share/applications/appimagekit-edex-ui-3.desktop
