From 37b14e3c8b6cf8f926a0e407b05cfca1e5f71406 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Mon, 10 Aug 2020 11:41:29 +0200 Subject: [PATCH] wrapper: fix second start with wrong profile Always start with --profile if there is no profiles.ini. Otherwise, firefox will create and use the profile for the first start only, but not set it as default. It would create a new profile on the second start then. --- src/mobile-config-firefox.sh | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/mobile-config-firefox.sh b/src/mobile-config-firefox.sh index 57be005..842395c 100644 --- a/src/mobile-config-firefox.sh +++ b/src/mobile-config-firefox.sh @@ -12,20 +12,28 @@ prepare_profile() { fi } -profile_found=false -for profiledir in ~/.mozilla/firefox/*/; do - if ! [ -e "$profiledir/prefs.js" ]; then - continue - fi +if [ -e ~/.mozilla/firefox/profiles.ini ]; then + # Firefox was started without this wrapper and created profiles.ini. + # Add the userChrome.css symlink to all existing profiles, then let + # firefox run with the default profile. - prepare_profile "$profiledir" - profile_found=true -done + for profiledir in ~/.mozilla/firefox/*/; do + if ! [ -e "$profiledir/prefs.js" ]; then + continue + fi + + prepare_profile "$profiledir" + done -if [ "$profile_found" = "true" ]; then exec /usr/bin/firefox "$@" else + # Firefox was not started without this wrapper. Create a profile dir + # called "firefox.default" if it does not exist yet, and add the + # userChrome.css symlink. Let firefox use this profile. It will not + # create the profiles.ini file. + profiledir=~/.mozilla/firefox/firefox.default prepare_profile "$profiledir" + exec /usr/bin/firefox --profile "$profiledir" "$@" fi