aboutsummaryrefslogtreecommitdiff
path: root/firefox-dev
blob: dc3e3c49f6db428620ad9476361ca93f43092b95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env bash
#
# Wrapper around firefox developer edition
#

# Parameters
DIRNAME="`dirname $0`"

if [ -e "$HOME/.local/bin/firefox-dev" ]; then
  # Manually or hoarder installed
  $HOME/.local/bin/firefox-dev
elif which hoarder &> /dev/null; then
  hoarder install firefox-dev && $HOME/.local/bin/firefox-dev
elif which flatpak &> /dev/null; then
  if ! flatpak list | grep -q ^org.mozilla.FirefoxDevEdition; then
    # Install
    sudo flatpak install -y --from https://firefox-flatpak.mojefedora.cz/org.mozilla.FirefoxDevEdition.flatpakref

    # Run this script again
    $0
  else
    # Check and set tridactyl
    if [ -e "$DIRNAME/../tridactyl/native/tridactyl.json" ]; then
      native="$HOME/.mozilla/native-messaging-hosts/"

      if [ ! -e "$native/tridactyl.json" ]; then
        mkdir -p $native

        tridactyl="`cd $DIRNAME/../tridactyl/native/ &> /dev/null && pwd`"
        cp $tridactyl/tridactyl.json $native
        sed -i -e "s|REPLACE_ME_WITH_SED|$tridactyl/native_main.py|g" $native/tridactyl.json
      fi
    fi

    flatpak run org.mozilla.FirefoxDevEdition &

    # Woraround while we dont fix this issue
    # https://elementaryos.stackexchange.com/questions/6796/why-does-firefox-keep-creating-a-desktop-folder
    # https://superuser.com/questions/1266254/prevent-firefox-from-creating-desktop-folder
    # http://docs.flatpak.org/en/latest/working-with-the-sandbox.html
    # https://www.mankier.com/1/flatpak-override
    while ! [ -d "$HOME/Desktop" ]; do
      sleep 2
    done

    rmdir $HOME/Desktop $HOME/Downloads &> /dev/null
  fi
else
  # Install flatpak
  sudo apt install flatpak -y

  # Run this script again
  $0
fi