Skip to content

Commit

Permalink
feat: Remove "themes" feature
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelmardojai committed Dec 3, 2024
1 parent 4b740df commit 09b0e8a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 84 deletions.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,6 @@ Here are some examples of how to use it:
- Set custom profile name, for example `e0j6yb0p.default-nightly`.
- Default: All the profiles found in the firefox folder

- `-t <theme_name>` *optional*
- Set the colors used in the theme.
- Default: Adwaita.
- Options: `adwaita`, `maia`.

<details>
<summary>Advanced notes</summary>

Expand Down
13 changes: 1 addition & 12 deletions scripts/auto-install.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#! /usr/bin/env bash

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")

firefoxInstallationPaths=(
# Firefox
~/.mozilla/firefox # Package
Expand All @@ -20,26 +17,18 @@ firefoxInstallationPaths=(

)

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 "${firefoxInstallationPaths[@]}"; do
if [ -d "$folder" ]; then
echo Firefox installation folder found

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

fi
Expand Down
54 changes: 17 additions & 37 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,17 @@
THEMEDIRECTORY=$(cd "$(dirname $0)" && cd .. && pwd)
FIREFOXFOLDER=~/.mozilla/firefox
PROFILENAME=""
THEME="DEFAULT"


# Get options.
while getopts 'f:p:t:' flag; do
case "${flag}" in
f) FIREFOXFOLDER="${OPTARG}" ;;
p) PROFILENAME="${OPTARG}" ;;
t) THEME="${OPTARG}" ;;
*)
echo "Gnome Theme Install Script:"
echo " -f <firefox_folder_path>. Set custom Firefox folder path."
echo " -p <profile_name>. Set custom profile name."
echo " -t <theme_name>. Set the colors used in the theme."
echo " -h to show this message."
exit 0
;;
Expand Down Expand Up @@ -66,19 +63,11 @@ function saveProfile(){
_sed -i '1s/^/@import "firefox-gnome-theme\/userChrome.css";\n/' userChrome.css

# Check if the import was set correctly
if ! cat userChrome.css | grep "firefox-gnome-theme" > /dev/null; then
echo "Unable to add the main import in 'userChrome.css', it needs to be set manually." >&2
fi

if [ "$THEME" = "DEFAULT" ]; then
echo "No theme set, using default adwaita." >&2
else
echo "Setting $THEME theme." >&2
echo "@import \"firefox-gnome-theme\/theme/colors/light-$THEME.css\";" >> userChrome.css
echo "@import \"firefox-gnome-theme\/theme/colors/dark-$THEME.css\";" >> userChrome.css
if ! cat userChrome.css | grep "firefox-gnome-theme" > /dev/null; then
echo "Unable to add the main import in 'userChrome.css', it needs to be set manually." >&2
fi

# Create single-line user content CSS files if non-existent or empty.
# Create single-line user content CSS files if non-existent or empty. (userContent)
if [ -s userContent.css ]; then
# Remove older theme imports
_sed 's/@import "firefox-gnome-theme.*.//g' userContent.css | _sed '/^\s*$/d' > tmpfile1 && mv tmpfile1 userContent.css
Expand All @@ -87,35 +76,27 @@ function saveProfile(){
echo >> userContent.css
fi

# Import this theme at the beginning of the CSS files.
_sed -i '1s/^/@import "firefox-gnome-theme\/userContent.css";\n/' userContent.css
# Import this theme at the beginning of the CSS files. (userContent)
_sed -i '1s/^/@import "firefox-gnome-theme\/userContent.css";\n/' userContent.css

# Check if the import was set correctly
if ! cat userContent.css | grep "firefox-gnome-theme" > /dev/null; then
echo "Unable to add the main import in 'userContent.css', it needs to be set manually." >&2
fi

if [ "$THEME" = "DEFAULT" ]; then
echo "No theme set, using default adwaita." >&2
else
echo "Setting $THEME theme."
echo "@import \"firefox-gnome-theme\/theme/colors/light-$THEME.css\";" >> userContent.css
echo "@import \"firefox-gnome-theme\/theme/colors/dark-$THEME.css\";" >> userContent.css
# Check if the import was set correctly (userContent)
if ! cat userContent.css | grep "firefox-gnome-theme" > /dev/null; then
echo "Unable to add the main import in 'userContent.css', it needs to be set manually." >&2
fi

cd ..

echo "Set configuration to user.js file" >&2

theme_prefs=()
while IFS= read -r line; do
theme_prefs+=("$line")
done < <(grep "user_pref" chrome/firefox-gnome-theme/configuration/user.js)
theme_prefs=()
while IFS= read -r line; do
theme_prefs+=("$line")
done < <(grep "user_pref" chrome/firefox-gnome-theme/configuration/user.js)

theme_prefs_unvalued=()
while IFS= read -r line; do
theme_prefs_unvalued+=("$line")
done < <(grep "user_pref" chrome/firefox-gnome-theme/configuration/user.js | cut -d'"' -f 2)
theme_prefs_unvalued=()
while IFS= read -r line; do
theme_prefs_unvalued+=("$line")
done < <(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 .
Expand Down Expand Up @@ -159,7 +140,6 @@ else
fi



if [ ${#PROFILES_ARRAY[@]} -eq 0 ]; then
echo "FAIL, no Firefox profile found in $PROFILES_FILE".;

Expand All @@ -168,7 +148,7 @@ else
do
if [[ -n "$i" ]];
then
echo "Installing ${THEME} theme for $(sed 's/SPACECHARACTER/ /g' <<< $i) profile.";
echo "Installing theme for $(sed 's/SPACECHARACTER/ /g' <<< $i) profile.";
saveProfile "$(sed 's/SPACECHARACTER/ /g' <<< $i)"
fi;
done
Expand Down
13 changes: 0 additions & 13 deletions theme/colors/dark-maia.css

This file was deleted.

17 changes: 0 additions & 17 deletions theme/colors/light-maia.css

This file was deleted.

0 comments on commit 09b0e8a

Please sign in to comment.