wget -q https://github.com/probonopd/AppImages/raw/master/functions.sh -O ./functions.sh
. ./functions.sh

APP=qTox
LOWERAPP=${APP,,}

mkdir -p $APP/$APP.AppDir/usr/bin
cd $APP/

wget -c "https://build.tox.chat/view/Clients/job/qTox_build_linux_x86-64_release/lastSuccessfulBuild/artifact/qTox_build_linux_x86-64_release.tar.xz"
tar xf *.tar.xz
cp ./qtox ./$APP.AppDir/usr/bin/

cd $APP.AppDir/

wget -c "https://raw.githubusercontent.com/tux3/qTox/master/qTox.desktop" -O $LOWERAPP.desktop
wget -c "https://raw.githubusercontent.com/tux3/qTox/master/img/icons/256x256/qtox.png" -O $LOWERAPP.png

get_apprun

VERSION=$( strings ./qTox.AppDir/usr/bin/qtox  | grep GIT_DESCRIBE -C 5 | grep ^v | head -n 1 | sed -e  's|-|.|g' | sed -e  's|v||g' )
echo $VERSION

get_desktopintegration $LOWERAPP

# Go out of AppImage
cd ..

generate_appimage
