#!/bin/sh

APP=ffwa-facebook
APPNAME="Facebook"
ICONURL="https://portable-linux-apps.github.io/icons/$APP.png"

# CREATING THE DIRECTORY
mkdir /opt/"$APP"
cd /opt/"$APP"

# ADD THE REMOVER
echo '#!/bin/sh' >> /opt/"$APP"/remove
echo "rm -R -f /usr/local/share/applications/$APP-AM.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/"$APP"/remove
chmod a+x /opt/"$APP"/remove

# LINK
cat >> /usr/local/bin/"$APP" << 'EOF'
#!/bin/sh
sh -c 'XAPP_FORCE_GTKWINDOW_ICON=/opt/ffwa-facebook/icons/ffwa-facebook firefox --class WebApp-facebook --profile /opt/ffwa-facebook --no-remote -url 'https://www.facebook.com''
EOF
chmod a+x /usr/local/bin/"$APP"

# LAUNCHER
echo "[Desktop Entry]
Name=$APPNAME
Exec=$APP
Icon=/opt/$APP/icons/$APP
Type=Application
Terminal=false
Categories=Network;
Comment=Web Application & Firefox Profile for $APPNAME" > /usr/local/share/applications/"$APP"-AM.desktop

# ICON
mkdir /opt/"$APP"/icons
wget "$ICONURL" -O /opt/"$APP"/icons/"$APP"

# ADD PREFERENCES
cat >> /opt/"$APP"/prefs.js << 'EOF'
// Mozilla User Preferences

// DO NOT EDIT THIS FILE.
//
// If you make changes to this file while the application is running,
// the changes will be overwritten when the application exits.
//
// To change a preference value, you can either:
// - modify it via the UI (e.g. via about:config in the browser); or
// - set it within a user.js file in your profile.

user_pref("app.normandy.first_run", false);
user_pref("browser.bookmarks.addedImportButton", true);
user_pref("browser.bookmarks.restore_default_bookmarks", false);
user_pref("browser.laterrun.enabled", true);
user_pref("browser.shell.checkDefaultBrowser", false);
user_pref("browser.shell.didSkipDefaultBrowserCheckOnFirstRun", true);
user_pref("browser.startup.couldRestoreSession.count", 2);
user_pref("browser.tabs.inTitlebar", 1);
user_pref("browser.toolbars.bookmarks.visibility", "never");
user_pref("browser.uiCustomization.state", "{\"placements\":{\"widget-overflow-fixed-list\":[],\"nav-bar\":[\"back-button\",\"forward-button\",\"stop-reload-button\",\"customizableui-special-spring1\",\"urlbar-container\",\"customizableui-special-spring2\",\"save-to-pocket-button\",\"downloads-button\",\"fxa-toolbar-menu-button\"],\"toolbar-menubar\":[\"menubar-items\"],\"TabsToolbar\":[\"tabbrowser-tabs\",\"new-tab-button\",\"alltabs-button\"],\"PersonalToolbar\":[\"import-button\",\"personal-bookmarks\"]},\"seen\":[\"save-to-pocket-button\",\"developer-button\"],\"dirtyAreaCache\":[\"nav-bar\",\"PersonalToolbar\",\"toolbar-menubar\",\"TabsToolbar\"],\"currentVersion\":17,\"newElementCount\":2}");
user_pref("browser.urlbar.placeholderName", "DuckDuckGo");
user_pref("doh-rollout.doneFirstRun", true);
user_pref("extensions.pendingOperations", false);

EOF




