Merge pull request 'symlink-config-home' (#1) from symlink-config-home into master
Reviewed-on: #1
This commit is contained in:
commit
5ce8c1def2
21
README.md
21
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:
|
||||
+ `<browser profile directory>/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
|
||||
+ `<browser profile directory>/chrome` will be created as a symlink to `$XDG_CONFIG_HOME/foxtheme/chrome/`
|
||||
+ `<browser profile directory>/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
|
||||
+ `<browser profile directory>/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.
|
||||
+ `<browser profile directory>/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/ <browser profile directory>/
|
||||
mkdir $XDG_CONFIG_DIR/foxtheme/
|
||||
cp -r chrome/ $XDG_CONFIG_DIR/foxtheme/
|
||||
ln -s -f $XDG_CONFIG_DIR/foxtheme/chrome/ <browser profile directory>
|
||||
cat user.js >> <browser profile directory>/user.js
|
||||
cat user.js >> <browser profile directory>/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.
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
50
foxtheme.sh
50
foxtheme.sh
|
@ -1,42 +1,70 @@
|
|||
#!/bin/sh
|
||||
|
||||
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; }
|
||||
|
||||
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 "$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 "$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
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue