From 007397c88e4167dcd46fab1543b990c93485d275 Mon Sep 17 00:00:00 2001 From: Moririn Date: Tue, 12 Sep 2023 16:53:05 +0100 Subject: [PATCH 1/4] Read theme from central $XDG_CONFIG_DIR location rather than being duplicated per profile --- foxtheme.sh | 49 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/foxtheme.sh b/foxtheme.sh index 21576ba..4cf172f 100755 --- a/foxtheme.sh +++ b/foxtheme.sh @@ -1,42 +1,69 @@ #!/bin/sh SCRIPTLOCATION=$(dirname -- "$(readlink -f "$0")") +XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" [ -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; } helptext() { echo "Usage: ./foxtheme.sh [OPTIONS] [PROFILE | -a PROFILESDIR] " - echo "-a Apply theme to all (current) browser profiles" - echo "-j Just create or modify user.js and not user-overrides.js" - echo "-o Remove and replace an existing theme if found" echo "-h Display this help message" + echo "-o Remove and replace an existing theme if found" + echo "-a Apply theme to all (current) browser profiles" + echo "-r Apply modifications to user-overrides.js instead of user.js" + echo "-d Don't modify existing user.js values. May cause the theme to behave incorrectly." } installtoprofile() { targetprofile="$1" + if [ "$OVERRIDES" ]; then + userjs="${targetprofile}/user-overrides.js" + else + userjs="${targetprofile}/user.js" + [ -f "$userjs" ] && echo "$0: Warning - Existing user.js file found at '$userjs' (pass -r to modify user-overrides.js instead)" + fi [ -d "$targetprofile" ] || { echo "$0: Profile at '$targetprofile' does not exist"; exit 2; } [ -d "$targetprofile/chrome/" ] && { - [ "$OVERWRITE" ] || { echo "$0: A theme for this profile '${targetprofile}/chrome/' already exists. Pass -o to overwrite existing themes."; exit 2; } - rm -r "${targetprofile:?}/chrome/" + [ "$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" } - cp -r "${SCRIPTLOCATION}/chrome/" "${targetprofile}/" - cat "${SCRIPTLOCATION}/user.js" >> "${targetprofile:?}/user.js" - [ "$NOOVERRIDE" ] || cat "${SCRIPTLOCATION}/user.js" >> "${targetprofile:?}/user-overrides.js" + [ -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" + fi + } + + mkdir -p "${XDG_CONFIG_HOME:?}/foxtheme/" + cp -r "${SCRIPTLOCATION:?}/chrome/" "${XDG_CONFIG_HOME:?}/foxtheme/" + ln -s -f "${XDG_CONFIG_HOME:?}/foxtheme/chrome/" "${targetprofile:?}" + [ -f "$userjs" ] || touch "$userjs" + for pref in $(sed --posix -e "s/^.*(\"//" -e "s/\",.*)\;$//" "${SCRIPTLOCATION}/user.js"); do + if [ "$NOCHANGEJS" ]; then + grep -q -s "$pref" "$userjs" || grep "\"$pref\"" "${SCRIPTLOCATION}/user.js" >> "$userjs" + else + sed -i "/\"$pref\"/d" "${userjs:?}" + grep "\"$pref\"" "${SCRIPTLOCATION}/user.js" >> "${userjs:?}" + fi + done echo "Successfully installed to '${targetprofile}'" } -while getopts "ajoh" opt; do +while getopts "hoard" opt; do case $opt in a) ALL=1 ;; - j) - NOOVERRIDE=1 + d) + NOCHANGEJS=1 ;; o) OVERWRITE=1 ;; + r) + OVERRIDES=1 + ;; h) helptext exit From 73998d6dd0822123d4482aa870923662d0008c5e Mon Sep 17 00:00:00 2001 From: Moririn Date: Tue, 12 Sep 2023 17:58:32 +0100 Subject: [PATCH 2/4] Make THEMEDIR a variable --- foxtheme.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) 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 From dac1af701dec6f27e8502c535687487f6fbd1b1e Mon Sep 17 00:00:00 2001 From: Moririn Date: Mon, 18 Sep 2023 16:46:57 +0100 Subject: [PATCH 3/4] Apply transparency to find and bookmarks bar --- chrome/components/window-transparencies.css | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/chrome/components/window-transparencies.css b/chrome/components/window-transparencies.css index 142b8bc..379ecf5 100644 --- a/chrome/components/window-transparencies.css +++ b/chrome/components/window-transparencies.css @@ -13,7 +13,7 @@ } /* navbar / tabbar / titlebar */ -#nav-bar { +#nav-bar, #TabsToolbar, #PersonalToolbar, findbar { background: transparent !important; border-color: transparent !important; } @@ -25,14 +25,6 @@ background: var(--bct-w-url-bg) !important; } -#TabsToolbar, #titlebar { - background: var(--bct-w-tab-bg) !important; - appearance: none; - -moz-appearance: none !important; - box-shadow: none !important; - border: none !important; -} - .tab-background[selected="true"] { background: var(--bct-w-tab-selected-bg) !important; } From 52b4a9f14c5a293ee966aab83ec17129881cf840 Mon Sep 17 00:00:00 2001 From: Moririn Date: Mon, 18 Sep 2023 17:01:58 +0100 Subject: [PATCH 4/4] Update README.md --- README.md | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index f1a2749..17a60e3 100644 --- a/README.md +++ b/README.md @@ -4,25 +4,26 @@ Included theme originally modified from [Filip Sutkowy's *blurclean-firefox-them ## Description This script will create or modify the following files and directories: -+ `/chrome/` and subsidiary CSS files will be created if they do not exist, or overwritten if `-o` is passed, in order to provide the necessary styles ++ `$XDG_CONFIG_HOME/foxtheme/chrome/` and subsidiary CSS files will be created if they do not exist, or overwritten if `-o` is passed, in order to provide the necessary styles ++ `/chrome` will be created as a symlink to `$XDG_CONFIG_HOME/foxtheme/chrome/` + `/user.js` will be created if it does not exist, or appended to in the case of an existing `user.js`, in order to modify the necessary `about:config` settings for the theme -+ `/user-overrides.js` will be created if it does not exist, or appended to in the case of an existing `user-overrides.js`, with the same modifications as the regular `user.js` file in order to ensure current or a potential future compatibility with the [arkenfox user.js (GitHub)](https://github.com/arkenfox/user.js) or similar - -Note: `user.js` files are read "top-to-bottom" by the browser, thus giving priority to the final alteration of a given preference that appears within the file. As such, the appending of the necessary preferences for this theme may overwrite users' existing settings for those preferences. ++ `/user-overrides.js` will be created instead of `user.js` if it does not exist and `-r` is passed, or appended to in the case of an existing `user-overrides.js`, with the same modifications as the regular `user.js` file in order to ensure current or a potential future compatibility with the [arkenfox user.js (GitHub)](https://github.com/arkenfox/user.js) or similar ## Options ``` Usage: ./foxtheme.sh [OPTIONS] [PROFILE | -a PROFILESDIR] --a Apply theme to all (current) browser profiles --j Just create or modify user.js and not user-overrides.js --o Remove and replace an existing theme if found -h Display this help message +-o Remove and replace an existing theme if found +-a Apply theme to all (current) browser profiles +-r Apply modifications to user-overrides.js instead of user.js +-d Don't modify existing user.js values. May cause the theme to behave incorrectly ``` ## Custom themes This script is ultimately just a glorified wrapper for: ``` -cp -r chrome/ / +mkdir $XDG_CONFIG_DIR/foxtheme/ +cp -r chrome/ $XDG_CONFIG_DIR/foxtheme/ +ln -s -f $XDG_CONFIG_DIR/foxtheme/chrome/ cat user.js >> /user.js -cat user.js >> /user-overrides.js ``` -As such, replacing the `user.js` or contents of the `chrome` directory with custom preferences and themes should offer the same functionality. +As such, replacing the supplied `user.js` or contents of the `chrome` directory with custom preferences and themes should offer the same functionality.