#!/usr/bin/env sh
if [ ! -e /var/lib/flatpak/exports/bin/org.mozilla.firefox ];then
    /usr/bin/biglinux-webapp "firelibre"
    exit
fi

FOLDER=~/.var/app/org.mozilla.firefox/data/jitsimeet-webapp-biglinux-org.mozilla.firefox
CLASS="webapp-jitsimeet-webapp-biglinux-org.mozilla.firefox"

if [ ! -d "$FOLDER" ];then
    mkdir -p "$FOLDER/chrome"
    cp -a /usr/share/bigbashview/bcc/apps/biglinux-webapps/profile/userChrome.css "$FOLDER/chrome"
    cp -a /usr/share/bigbashview/bcc/apps/biglinux-webapps/profile/user.js "$FOLDER"
fi

MOZ_DISABLE_GMP_SANDBOX=1 MOZ_DISABLE_CONTENT_SANDBOX=1 \
XAPP_FORCE_GTKWINDOW_ICON=/usr/share/icons/hicolor/128x128/apps/webapp-jitsi.svg \
/var/lib/flatpak/exports/bin/org.mozilla.firefox --class="$CLASS" --profile "$FOLDER" --no-remote --new-instance "https://meet.jit.si/" &
