Preserve existing user.js in profile folder when applying theme prefs

This commit is contained in:
bbhtt 2023-03-31 08:35:34 +05:30 committed by Rafael Mardojai CM
parent 0cc285bf22
commit cb871e5055
1 changed files with 18 additions and 5 deletions

View File

@ -78,10 +78,24 @@ function saveProfile(){
cd ..
# Symlink user.js to firefox-gnome-theme one.
echo "Set configuration user.js file" >&2
ln -is chrome/firefox-gnome-theme/configuration/user.js user.js
echo "Set configuration to user.js file" >&2
mapfile -t theme_prefs < <( grep "user_pref" chrome/firefox-gnome-theme/configuration/user.js )
mapfile -t theme_prefs_unvalued < <( grep "user_pref" chrome/firefox-gnome-theme/configuration/user.js|cut -d'"' -f 2 )
if [ ! -f "user.js" ]; then
mv chrome/firefox-gnome-theme/configuration/user.js .
else
cp user.js user.js.bak
OLDIFS=$IFS
IFS='/'
for t in "${theme_prefs_unvalued[@]}"; do
sed -i "/$t/d" "user.js"
done
for f in "${theme_prefs[@]}"; do
echo "$f" >> "user.js"
done
IFS=$OLDIFS
fi
echo "Done." >&2
cd ..
}
@ -122,6 +136,5 @@ else
echo "Installing ${THEME} theme for $(sed 's/SPACECHARACTER/ /g' <<< $i) profile.";
saveProfile "$(sed 's/SPACECHARACTER/ /g' <<< $i)"
fi;
done
fi