EliverLara / firefox-sweet-theme

:candy: A dark and modern theme for firefox with vibrant colors
748 stars 34 forks source link

Install script broken on Linux #83

Open simonbcn opened 1 year ago

simonbcn commented 1 year ago
Arch Linux
❯ ./scripts/install.sh
./scripts/install.sh: line 26: cd: /home/juan/.mozilla/firefox//*.default: No such file or directory
Installing theme in /home/juan/fuentes/firefox-sweet-theme
Coping repo in /home/juan/fuentes/firefox-sweet-theme/chrome
cp: cannot copy a directory, '/home/juan/fuentes/firefox-sweet-theme', into itself, '/home/juan/fuentes/firefox-sweet-theme/chrome/firefox-sweet-theme'
Set configuration user.js file
Done.

I have checked the installation script and fixed it:

#!/bin/bash

THEMEDIRECTORY=$(cd `dirname $0` && cd .. && pwd)
FIREFOXFOLDER=~/.mozilla/firefox
PROFILENAME=""
GNOMISHEXTRAS=false

# Get options.
while getopts 'f:p:g' flag; do
    case "${flag}" in    
        f) FIREFOXFOLDER="${OPTARG}" ;;
        p) PROFILENAME="${OPTARG}" ;;
        g) GNOMISHEXTRAS=true ;;
    esac
done

# Define profile folder path.
if test -z "$PROFILENAME" 
    then
        PROFILEFOLDER="$FIREFOXFOLDER/*.default*"
    else
        PROFILEFOLDER="$FIREFOXFOLDER/$PROFILENAME"
fi

if [ -d $PROFILEFOLDER ]; then
    # Enter Firefox profile folder.
    cd $PROFILEFOLDER
    echo "Installing theme in $PWD"

    # Create a chrome directory if it doesn't exist.
    mkdir -p chrome
    cd chrome

    # Copy theme repo inside
    echo "Coping repo in $PWD"
    cp -R $THEMEDIRECTORY $PWD

    # Create single-line user CSS files if non-existent or empty.
    [[ -s userChrome.css ]] || echo >> userChrome.css

    # Import this theme at the beginning of the CSS files.
    sed -i '1s/^/@import "firefox-sweet-theme\/userChrome.css";\n/' userChrome.css

    # If GNOMISH extras enabled, import it in customChrome.css.
    if [ "$GNOMISHEXTRAS" = true ] ; then
        echo "Enabling GNOMISH extra features"
        [[ -s customChrome.css ]] || echo >> firefox-sweet-theme/customChrome.css
        sed -i '1s/^/@import "theme\/hide-single-tab.css";\n/' firefox-sweet-theme/customChrome.css
        sed -i '2s/^/@import "theme\/matching-autocomplete-width.css";\n/' firefox-sweet-theme/customChrome.css
    fi

    # Symlink user.js to firefox-sweet-theme one.
    echo "Set configuration user.js file"
    ln -s chrome/firefox-sweet-theme/configuration/user.js ../user.js

    echo "Done."
else
    echo "Error: Profile folder ($PROFILEFOLDER) doesn't exist"
fi

The end / was left over in the first FIREFOXFOLDER. A final * was missing in the first PROFILEFOLDER. Generally, installations from the corresponding Linux package create a folder ending in .default-release. And it is very important to check that the folder really exists before modifying things in the file system: if [ -d $PROFILEFOLDER ]; then.