diff --git a/foxtheme.sh b/foxtheme.sh index 4cf172f..d33d9e5 100755 --- a/foxtheme.sh +++ b/foxtheme.sh @@ -2,6 +2,7 @@ SCRIPTLOCATION=$(dirname -- "$(readlink -f "$0")") XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" +THEMEDIR="$XDG_CONFIG_HOME/foxtheme" [ -d "$SCRIPTLOCATION" ] || { echo "$0: Could not verify script location as an existing directory. This is probably a bug."; exit 2; } [ -d "$SCRIPTLOCATION"/chrome ] || { echo "$0: Could not proceed with installation as 'chrome' directory is missing from '$SCRIPTLOCATION'."; exit 2; } [ -f "$SCRIPTLOCATION"/user.js ] || { echo "$0: Could not proceed with installation as 'user.js' file is missing from '$SCRIPTLOCATION'."; exit 2; } @@ -28,16 +29,16 @@ installtoprofile() { [ "$OVERWRITE" ] || { echo "$0: A theme for this profile already exists at '${targetprofile}/chrome/'. Pass -o to overwrite existing themes."; exit 2; } rm -r -f "${targetprofile:?}/chrome" } - [ -d "$XDG_CONFIG_HOME"/foxtheme/chrome ] && { - if ! diff -q "${SCRIPTLOCATION}/chrome" "${XDG_CONFIG_HOME}/foxtheme/chrome" >/dev/null 2>&1; then - [ "$OVERWRITE" ] || { echo "$0: A theme already exists at '${XDG_CONFIG_HOME}/foxtheme/chrome/'. Pass -o to overwrite existing themes."; exit 2; } - rm -r -f "${XDG_CONFIG_HOME:?}/foxtheme/chrome" + [ -d "$THEMEDIR"/chrome ] && { + if ! diff -q "${SCRIPTLOCATION}/chrome" "$THEMEDIR/chrome" >/dev/null 2>&1; then + [ "$OVERWRITE" ] || { echo "$0: A theme already exists at '$THEMEDIR/chrome/'. Pass -o to overwrite existing themes."; exit 2; } + rm -r -f "${THEMEDIR:?}/chrome" fi } - mkdir -p "${XDG_CONFIG_HOME:?}/foxtheme/" - cp -r "${SCRIPTLOCATION:?}/chrome/" "${XDG_CONFIG_HOME:?}/foxtheme/" - ln -s -f "${XDG_CONFIG_HOME:?}/foxtheme/chrome/" "${targetprofile:?}" + mkdir -p "$THEMEDIR/" + cp -r "${SCRIPTLOCATION:?}/chrome/" "${THEMEDIR:?}" + ln -s -f "${THEMEDIR:?}/chrome/" "${targetprofile:?}" [ -f "$userjs" ] || touch "$userjs" for pref in $(sed --posix -e "s/^.*(\"//" -e "s/\",.*)\;$//" "${SCRIPTLOCATION}/user.js"); do if [ "$NOCHANGEJS" ]; then