fix installation folder

This commit is contained in:
Dyego Aurélio 2020-10-22 20:39:57 -03:00
parent b3ec1cc9c7
commit 1b07537055
1 changed files with 57 additions and 45 deletions

View File

@ -30,56 +30,68 @@ while getopts 'f:p:g:t:h' flag; do
esac esac
done done
# Define profile folder path. function saveProfile(){
if test -z "$PROFILENAME" cd $FIREFOXFOLDER/$PROFILE_PATH
then echo "Installing theme in $PWD"
PROFILEFOLDER="$FIREFOXFOLDER/$(current_profile)" # Create a chrome directory if it doesn't exist.
else mkdir -p chrome
PROFILEFOLDER="$FIREFOXFOLDER/$PROFILENAME" cd chrome
fi
# Enter Firefox profile folder. # Copy theme repo inside
if ! cd $PROFILEFOLDER ; then echo "Copying repo in $PWD"
echo "Error entering profile folder." cp -fR $THEMEDIRECTORY $PWD
echo "Try using -p flag to specify a custom profile name."
# Create single-line user CSS files if non-existent or empty.
if [ -s userChrome.css ]; then
# Remove older theme imports
sed 's/@import "firefox-gnome-theme.*.//g' userChrome.css | sed '/^\s*$/d' > userChrome.css
echo >> userChrome.css
else
echo >> userChrome.css
fi
# Import this theme at the beginning of the CSS files.
sed -i '1s/^/@import "firefox-gnome-theme\/userChrome.css";\n/' userChrome.css
if [ $THEME = "DEFAULT" ]; then
echo "No theme set, using default adwaita."
else
echo "Setting $THEME theme."
echo "@import \"firefox-gnome-theme\/theme/colors/light-$THEME.css\";" >> userChrome.css
echo "@import \"firefox-gnome-theme\/theme/colors/dark-$THEME.css\";" >> userChrome.css
fi
cd ..
# Symlink user.js to firefox-gnome-theme one.
echo "Set configuration user.js file"
ln -fs chrome/firefox-gnome-theme/configuration/user.js user.js
echo "Done."
cd ..
}
PROFILES_FILE="${FIREFOXFOLDER}/profiles.ini"
if [ ! -f "${PROFILES_FILE}" ]; then
>&2 echo "failed, lease check Firefox installation, unable to find profile.ini at ${FIREFOX_DIR}"
exit 1 exit 1
fi fi
echo "Profiles file found"
echo "Installing theme in $PWD" PROFILES_PATHS=($(grep -E "^Path=" "${PROFILES_FILE}" | cut -d "=" -f2-))
# Create a chrome directory if it doesn't exist. if [ ${#PROFILES_PATHS[@]} -eq 0 ]; then
mkdir -p chrome >&2 echo "failed, no profiles found at ${PROFILES_FILE}"
cd chrome exit 0
elif [ ${#PROFILES_PATHS[@]} -eq 1 ]; then
# Copy theme repo inside echo "one profile found"
echo "Copying repo in $PWD" saveProfile "0" "${PROFILES_PATHS[0]}"
cp -fR $THEMEDIRECTORY $PWD
# Create single-line user CSS files if non-existent or empty.
if [ -s userChrome.css ]; then
# Remove older theme imports
sed 's/@import "firefox-gnome-theme.*.//g' userChrome.css | sed '/^\s*$/d' > userChrome.css
echo >> userChrome.css
else else
echo >> userChrome.css echo "${#PROFILES_PATHS[@]} profiles found"
ITEM=0
for PROFILE_PATH in "${PROFILES_PATHS[@]}"; do
saveProfile "${ITEM}" "${PROFILE_PATH}"
ITEM="$((${ITEM}+1))"
done
fi fi
# Import this theme at the beginning of the CSS files.
sed -i '1s/^/@import "firefox-gnome-theme\/userChrome.css";\n/' userChrome.css
if [ $THEME = "DEFAULT" ]; then
echo "No theme set, using default adwaita."
else
echo "Setting $THEME theme."
echo "@import \"firefox-gnome-theme\/theme/colors/light-$THEME.css\";" >> userChrome.css
echo "@import \"firefox-gnome-theme\/theme/colors/dark-$THEME.css\";" >> userChrome.css
fi
cd ..
# Symlink user.js to firefox-gnome-theme one.
echo "Set configuration user.js file"
ln -fs chrome/firefox-gnome-theme/configuration/user.js user.js
echo "Done."