I’m working on a suite of scripts that will enable me to hop Linux distros and get back to business as usual w/ minimal fuss. When I hop distros, I tend to back up my important stuff and blow everything else away so I can start with a clean slate. I have some scripts for updating my backups before the wipe and updating the system after the base install:

sudo apt update && sudo apt upgrade -y

Followed by other commands to install my favorite apps and configure my favorite desktop settings.

One thing that I haven’t nailed down yet is restoring my Firefox add-ons through the command line. Searching the web, I’m not even sure this is feasible. I found this post from 2011 in the AskUbuntu forum, but I figure the answer might have changed since then.

I just want to remove as much friction as possible from the distro hopping process. I know I can store /home on a separate partition, but I prefer nice, clean installs followed by scripting in my config changes.

Any tips or advice would be greatly appreciated.

    • yo_scottie_oh@lemmy.mlOP
      link
      fedilink
      English
      arrow-up
      14
      ·
      3 days ago

      Why not just keep /home on a separate partition?

      My issue is that over time, a lot of cruft builds up in there from apps I no longer use. I like things nice and clean.

      Or just backup ~/.mozilla/?

      The thought has crossed my mind. Maybe I should try this next time. Thanks for the idea.

    • GenderNeutralBro@lemmy.sdf.org
      link
      fedilink
      English
      arrow-up
      2
      ·
      3 days ago

      Perhaps this goes without saying, but if you want to do that, be sure you are installing Firefox through similar means across distros. This will not work with the Flatpak, for example.

      Manual installation of Firefox is quite simple, and it self-updates, so that’s always an option.

      • yo_scottie_oh@lemmy.mlOP
        link
        fedilink
        English
        arrow-up
        2
        ·
        edit-2
        2 days ago

        be sure you are installing Firefox through similar means across distros. This will not work with the Flatpak, for example.

        Very good point, I’ve picked up on this as well. Installed through the native package manager, the profile folder lives under ~/.mozilla/ whereas for flatpaks it’s under ~/.var/app/org.mozilla.firefox/.mozilla/.

  • HouseWolf@pawb.social
    link
    fedilink
    arrow-up
    13
    ·
    3 days ago

    You can backup your .mozilla file from your home to a new install and it’ll keep the everything how it was.

    I’ve done it a few times now.

  • kalkulat@lemmy.world
    link
    fedilink
    English
    arrow-up
    4
    ·
    edit-2
    3 days ago

    I install and use FF from my home folder. As a result, I can simply copy my ‘old’ firefox folder and .mozilla folder (containing the FF config files) into the new distro’s home. That way all of the features, settings, and extensions remain the same, regardless of the distro I’ve moved to.

    Inside the .mozilla/Firefox/ folder you’ll find separate folders for your profiles. The ‘about:profiles’ window lets you switch between them.If you want to experiment with one, make an archive of its folder. If you try something that doesn’t work out, you can throw the messed-up profile away and extract a fresh copy from your archive, all’s well. There are also many files INSIDE that profile folder you can toy with. Many, many options in this setup.

    • Ephera@lemmy.ml
      link
      fedilink
      English
      arrow-up
      2
      ·
      3 days ago

      The chance of that working well across distros is pretty low, though, unfortunately…

  • redxef@feddit.org
    link
    fedilink
    arrow-up
    4
    ·
    edit-2
    3 days ago

    I use something like this:

    #!/bin/bash
    
    set -euo pipefail
    URLS=(
        'https://addons.mozilla.org/en-US/firefox/addon/ublock-origin/'
        'https://addons.mozilla.org/en-US/firefox/addon/privacy-badger17/'
        'https://addons.mozilla.org/en-US/firefox/addon/passff/'
        'https://addons.mozilla.org/en-US/firefox/addon/copy-plaintext/'
        'https://addons.mozilla.org/en-US/firefox/addon/duckduckgo-for-firefox/'
        'https://addons.mozilla.org/en-US/firefox/addon/user-agent-string-switcher/'
        'https://addons.mozilla.org/en-US/firefox/addon/clearurls/'
        'https://addons.mozilla.org/en-US/firefox/addon/temporary-containers/'
        'https://addons.mozilla.org/en-US/firefox/addon/consent-o-matic/'
    )
    
    DOWNLOAD_BASE_URL='https://addons.mozilla.org/firefox/downloads/latest'
    _="${FIREFOX:=firefox}"
    _="${DST:=/usr/lib/$FIREFOX/browser/extensions}"
    
    if [ $UID -eq 0 ]; then
        SUDO=
    else
        SUDO=sudo
    fi
    
    
    download_links=()
    for url in "${URLS[@]}"; do
        package_name="$(sed 's_/$__' <<< "$url" | awk -F/ '{print $NF}')"
        download_links+=("$DOWNLOAD_BASE_URL/$package_name/addon-$package_name.xpi")
    done
    
    workdir="$(mktemp --directory)"
    cd "$workdir"
    for url in "${download_links[@]}"; do
        curl -OL "$url"
    done
    
    for ext in *.xpi; do
        ext_id="$(unzip -p "$ext" 'manifest.json' | jq -r '(if .browser_specific_settings then .browser_specific_settings else .applications end).gecko.id')"
        target="$DST/$ext_id.xpi"
        echo "$ext -> $target"
        $SUDO install -Dm644 "$ext" "$target"
    done
    

    That doesn’t handle the extension config though.

  • Trey A@lemmy.world
    link
    fedilink
    English
    arrow-up
    4
    ·
    3 days ago

    Any particular reason you don’t just sign in? Genuine question, and you could even create a dummy account that solely holds those extensions and anything else you would want to sync.

    • bayleaf@piefed.ca
      link
      fedilink
      English
      arrow-up
      1
      ·
      3 days ago

      I see two parts to OP’s question in the title. The first part is installing the extensions and the second part is configuring them. Firefox Sync will automatically install your extensions on a new device, but in the extensions that I’ve tested, the extension settings will not carry over.

      • Trey A@lemmy.world
        link
        fedilink
        English
        arrow-up
        2
        ·
        3 days ago

        Ahh, very interesting, and excellent point. Thank you for clarifying! I’ve pretty much just used simple extensions like Return YT Dislike and Grammarly, and the few extensions I use that I DO want settings to sync across devices for usually have a setting for it. That’s definitely good to know though, and I’ll keep that in mind for my tech support for the future!

  • hankthetankie [none/use name]@hexbear.net
    link
    fedilink
    English
    arrow-up
    4
    ·
    3 days ago

    Unsure, but what you can do is copy the extensions from your Firefox user folder and add them to your new install. The settings are not stored in the same folder as the rest of the settings or extension settings.

    • yo_scottie_oh@lemmy.mlOP
      link
      fedilink
      English
      arrow-up
      5
      ·
      3 days ago

      I was just thinking about whether something like this could work after eksb’s comment about backing up the ~/.mozilla folder. I’ll test it on a test machine and report back.