Skip to content

Commit

Permalink
Add auto install script for easy installation
Browse files Browse the repository at this point in the history
fixes #185
  • Loading branch information
dyegoaurelio authored May 10, 2021
1 parent 418f97e commit 6bb1d9e
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 17 deletions.
37 changes: 37 additions & 0 deletions scripts/auto-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
sysThemeNames=("'Pop'" "'Pop-dark'" "'Pop-light'" "'Yaru'" "'Yaru-dark'" "'Yaru-light'" "'Adwaita-maia'" "'Adwaita-maia-dark'")
themeNames=("pop" "pop" "pop" "yaru" "yaru" "yaru" "maia" "maia")

firefoxInstalationPaths=(
~/.mozilla/firefox
~/.var/app/org.mozilla.firefox/.mozilla/firefox
)

currentTheme=$(gsettings get org.gnome.desktop.interface gtk-theme ) || currentTheme=""
installScript="./scripts/install.sh"
themeArg=""
folderArg=""
foldersFoundCount=0

eval "chmod +x ${installScript}"

for i in "${!sysThemeNames[@]}"; do
if [[ "${sysThemeNames[$i]}" = "${currentTheme}" ]]; then
themeArg=" -t ${themeNames[i]}"
fi
done

for folder in "${firefoxInstalationPaths[@]}"; do
if [ -d $folder ]; then
echo Firefox installation folder found

folderArg=" -f $folder"
eval ${installScript}${themeArg}${folderArg}
foldersFoundCount+=1

fi

done

if [ $foldersFoundCount = 0 ];then
echo No firefox folder found ;
fi
6 changes: 3 additions & 3 deletions scripts/install-by-curl.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

VERSION=$(curl -s "https://github.com/rafaelmardojai/firefox-gnome-theme/releases/latest/download" 2>&1 | sed "s/^.*download\/\([^\"]*\).*/\1/")
FILENAME=firefox-gnome-theme-$VERSION.tar.gz
FOLDERPATH=$PWD/firefox-gnome-theme
Expand All @@ -14,7 +13,8 @@ curl -LJo $FILENAME https://github.com/rafaelmardojai/firefox-gnome-theme/tarbal
tar -xzf $FILENAME --strip-components=1
rm $FILENAME

chmod +x scripts/install.sh
./scripts/install.sh
chmod +x scripts/auto-install.sh

./auto-install.sh

if [ -d "$FOLDERPATH" ]; then rm -Rf $FOLDERPATH; fi
37 changes: 23 additions & 14 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ done
function saveProfile(){
local PROFILE_PATH="$1"

cd $FIREFOXFOLDER/$PROFILE_PATH
cd "$FIREFOXFOLDER/$PROFILE_PATH"
echo "Installing theme in $PWD"
# Create a chrome directory if it doesn't exist.
mkdir -p chrome
cd chrome

# Copy theme repo inside
echo "Copying repo in $PWD"
cp -fR $THEMEDIRECTORY $PWD
cp -fR "$THEMEDIRECTORY" "$PWD"

# Create single-line user CSS files if non-existent or empty.
if [ -s userChrome.css ]; then
Expand Down Expand Up @@ -73,18 +73,27 @@ if [ ! -f "${PROFILES_FILE}" ]; then
fi
echo "Profiles file found"

PROFILES_PATHS=($(grep -E "^Path=" "${PROFILES_FILE}" | cut -d "=" -f2-))
PROFILES_PATHS=($(grep -E "^Path=" "${PROFILES_FILE}" | tr -d '\n' | sed -e 's/\s\+/SPACECHARACTER/g' | sed 's/Path=/::/g' ))
PROFILES_PATHS+=::

PROFILES_ARRAY=()
while [[ $PROFILES_PATHS ]]; do
PROFILES_ARRAY+=( "${PROFILES_PATHS%%::*}" )
PROFILES_PATHS=${PROFILES_PATHS#*::}
done


if [ ${#PROFILES_ARRAY[@]} -eq 0 ]; then
echo No Profiles found on $PROFILES_FILE;

if [ ${#PROFILES_PATHS[@]} -eq 0 ]; then
>&2 echo "failed, no profiles found at ${PROFILES_FILE}"
exit 0
elif [ ${#PROFILES_PATHS[@]} -eq 1 ]; then
echo "One profile found"
saveProfile "${PROFILES_PATHS[0]}"
else
echo "${#PROFILES_PATHS[@]} profiles found"
for PROFILE_PATH in "${PROFILES_PATHS[@]}"; do
saveProfile "${PROFILE_PATH}"
for i in "${PROFILES_ARRAY[@]}"
do
if [[ ! -z "$i" ]];
then
echo Installing Theme on $(sed 's/SPACECHARACTER/ /g' <<< $i) ;
saveProfile "$(sed 's/SPACECHARACTER/ /g' <<< $i)"
fi;

done
fi

fi

0 comments on commit 6bb1d9e

Please sign in to comment.