Skip to content

Commit 6bb1d9e

Browse files
authored
Add auto install script for easy installation
fixes #185
1 parent 418f97e commit 6bb1d9e

File tree

3 files changed

+63
-17
lines changed

3 files changed

+63
-17
lines changed

scripts/auto-install.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
sysThemeNames=("'Pop'" "'Pop-dark'" "'Pop-light'" "'Yaru'" "'Yaru-dark'" "'Yaru-light'" "'Adwaita-maia'" "'Adwaita-maia-dark'")
2+
themeNames=("pop" "pop" "pop" "yaru" "yaru" "yaru" "maia" "maia")
3+
4+
firefoxInstalationPaths=(
5+
~/.mozilla/firefox
6+
~/.var/app/org.mozilla.firefox/.mozilla/firefox
7+
)
8+
9+
currentTheme=$(gsettings get org.gnome.desktop.interface gtk-theme ) || currentTheme=""
10+
installScript="./scripts/install.sh"
11+
themeArg=""
12+
folderArg=""
13+
foldersFoundCount=0
14+
15+
eval "chmod +x ${installScript}"
16+
17+
for i in "${!sysThemeNames[@]}"; do
18+
if [[ "${sysThemeNames[$i]}" = "${currentTheme}" ]]; then
19+
themeArg=" -t ${themeNames[i]}"
20+
fi
21+
done
22+
23+
for folder in "${firefoxInstalationPaths[@]}"; do
24+
if [ -d $folder ]; then
25+
echo Firefox installation folder found
26+
27+
folderArg=" -f $folder"
28+
eval ${installScript}${themeArg}${folderArg}
29+
foldersFoundCount+=1
30+
31+
fi
32+
33+
done
34+
35+
if [ $foldersFoundCount = 0 ];then
36+
echo No firefox folder found ;
37+
fi

scripts/install-by-curl.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
VERSION=$(curl -s "https://github.com/rafaelmardojai/firefox-gnome-theme/releases/latest/download" 2>&1 | sed "s/^.*download\/\([^\"]*\).*/\1/")
32
FILENAME=firefox-gnome-theme-$VERSION.tar.gz
43
FOLDERPATH=$PWD/firefox-gnome-theme
@@ -14,7 +13,8 @@ curl -LJo $FILENAME https://github.com/rafaelmardojai/firefox-gnome-theme/tarbal
1413
tar -xzf $FILENAME --strip-components=1
1514
rm $FILENAME
1615

17-
chmod +x scripts/install.sh
18-
./scripts/install.sh
16+
chmod +x scripts/auto-install.sh
17+
18+
./auto-install.sh
1919

2020
if [ -d "$FOLDERPATH" ]; then rm -Rf $FOLDERPATH; fi

scripts/install.sh

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ done
2626
function saveProfile(){
2727
local PROFILE_PATH="$1"
2828

29-
cd $FIREFOXFOLDER/$PROFILE_PATH
29+
cd "$FIREFOXFOLDER/$PROFILE_PATH"
3030
echo "Installing theme in $PWD"
3131
# Create a chrome directory if it doesn't exist.
3232
mkdir -p chrome
3333
cd chrome
3434

3535
# Copy theme repo inside
3636
echo "Copying repo in $PWD"
37-
cp -fR $THEMEDIRECTORY $PWD
37+
cp -fR "$THEMEDIRECTORY" "$PWD"
3838

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

76-
PROFILES_PATHS=($(grep -E "^Path=" "${PROFILES_FILE}" | cut -d "=" -f2-))
76+
PROFILES_PATHS=($(grep -E "^Path=" "${PROFILES_FILE}" | tr -d '\n' | sed -e 's/\s\+/SPACECHARACTER/g' | sed 's/Path=/::/g' ))
77+
PROFILES_PATHS+=::
78+
79+
PROFILES_ARRAY=()
80+
while [[ $PROFILES_PATHS ]]; do
81+
PROFILES_ARRAY+=( "${PROFILES_PATHS%%::*}" )
82+
PROFILES_PATHS=${PROFILES_PATHS#*::}
83+
done
84+
85+
86+
if [ ${#PROFILES_ARRAY[@]} -eq 0 ]; then
87+
echo No Profiles found on $PROFILES_FILE;
7788

78-
if [ ${#PROFILES_PATHS[@]} -eq 0 ]; then
79-
>&2 echo "failed, no profiles found at ${PROFILES_FILE}"
80-
exit 0
81-
elif [ ${#PROFILES_PATHS[@]} -eq 1 ]; then
82-
echo "One profile found"
83-
saveProfile "${PROFILES_PATHS[0]}"
8489
else
85-
echo "${#PROFILES_PATHS[@]} profiles found"
86-
for PROFILE_PATH in "${PROFILES_PATHS[@]}"; do
87-
saveProfile "${PROFILE_PATH}"
90+
for i in "${PROFILES_ARRAY[@]}"
91+
do
92+
if [[ ! -z "$i" ]];
93+
then
94+
echo Installing Theme on $(sed 's/SPACECHARACTER/ /g' <<< $i) ;
95+
saveProfile "$(sed 's/SPACECHARACTER/ /g' <<< $i)"
96+
fi;
97+
8898
done
89-
fi
90-
99+
fi

0 commit comments

Comments
 (0)