#!/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
}

wget https://github.com/Itai-Nelken/Nativefier-Whatsapp-Web/releases/download/v1.0/WhatsAppWeb-linux-armv7l.tray.tar.xz || error 'Failed to download!'
tar -xf WhatsAppWeb-linux-armv7l.tray.tar.xz || error "Failed to extract!"
rm WhatsAppWeb-linux-armv7l.tray.tar.xz
mv "WhatsAppWeb-linux-armv7l(tray)" WhatsAppWeb

echo "[Desktop Entry]
Name=Whatsapp Web
Comment=Nativefier Whatsapp Web webapp.
Exec=$HOME/WhatsAppWeb/WhatsAppWeb
Path=$HOME/WhatsAppWeb
Icon=$(dirname "$0")/icon-64.png
Terminal=false
StartupNotify=true
Type=Application
Categories=Network;" > ~/.local/share/applications/whatsappweb.desktop || error "Failed to create menu button!"
