From 6bb1d9e7c94bf718125cecab50aa43837a728f19 Mon Sep 17 00:00:00 2001 From: dyegoaurelio <42411160+dyegoaurelio@users.noreply.github.com> Date: Mon, 10 May 2021 11:54:01 -0300 Subject: [PATCH] Add auto install script for easy installation fixes #185 --- scripts/auto-install.sh | 37 +++++++++++++++++++++++++++++++++++++ scripts/install-by-curl.sh | 6 +++--- scripts/install.sh | 37 +++++++++++++++++++++++-------------- 3 files changed, 63 insertions(+), 17 deletions(-) create mode 100755 scripts/auto-install.sh diff --git a/scripts/auto-install.sh b/scripts/auto-install.sh new file mode 100755 index 00000000..bf973959 --- /dev/null +++ b/scripts/auto-install.sh @@ -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 \ No newline at end of file diff --git a/scripts/install-by-curl.sh b/scripts/install-by-curl.sh index 945a9c68..4a0a7b8c 100755 --- a/scripts/install-by-curl.sh +++ b/scripts/install-by-curl.sh @@ -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 @@ -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 \ No newline at end of file diff --git a/scripts/install.sh b/scripts/install.sh index 20216d0f..d8181bf7 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -26,7 +26,7 @@ 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 @@ -34,7 +34,7 @@ function saveProfile(){ # 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 @@ -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 \ No newline at end of file