Skip to content

Commit f021235

Browse files
committed
Initial commit
0 parents  commit f021235

File tree

189 files changed

+9012
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

189 files changed

+9012
-0
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Vince
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
2+
## Firefox Safari theme
3+
4+
<p align="center">A MacOSX Safari theme for Firefox 80+</p>
5+
6+
#### Preview
7+
![01](https://github.com/vinceliuice/WhiteSur-gtk-theme/blob/pictures/pictures/firefox-whitesur.png?raw=true)
8+
9+
## Description
10+
11+
This is a bunch of CSS code to make Firefox look closer to MacOSX Safari theme.
12+
Based on https://github.com/rafaelmardojai/firefox-gnome-theme
13+
14+
## Installation
15+
16+
Run `./install.sh`
17+
18+
if you want to edit the style then:
19+
20+
Run `./install.sh -f -e`
21+
22+
if you want to use `Monterey` style then:
23+
24+
Run `./install.sh -f monterey`
25+
26+
![01](https://github.com/vinceliuice/WhiteSur-gtk-theme/blob/pictures/pictures/firefox-monterey.png?raw=true)
27+
28+
### Manual installation
29+
30+
1. Go to `about:support` in Firefox.
31+
2. Application Basics > Profile Directory > Open Directory.
32+
3. Copy `chrome` folder Firefox config folder.
33+
4. If you are using Firefox 69+:
34+
1. Go to `about:config` in Firefox.
35+
2. Search for `toolkit.legacyUserProfileCustomizations.stylesheets` and set it to `true`.
36+
5. Restart Firefox.
37+
6. Open Firefox customization panel and:
38+
1. Use *Title bar* option to toggle CSD if is not set by default.
39+
2. Move the new tab button to headerbar.
40+
3. Select light or dark variants on theme switcher.
41+
7. Be happy with your new gnomish Firefox.
42+
43+
## Enabling optional features
44+
Open `userChrome.css` with a text editor and follow instructions to enable extra features. Keep in mind this file might change in future versions and your configuration will be lost. You can copy the @imports you want to enable to a new file named `customChrome` directly in your `chrome` directory if you want it to survive updates. Remember all @imports must be at the top of the file, before other statements.
45+
46+
## Known bugs
47+
48+
### CSD have sharp corners
49+
See upstream [bug](https://bugzilla.mozilla.org/show_bug.cgi?id=1408360).
50+
51+
#### Wayland fix:
52+
1. Go to the `about:config` page
53+
2. Search for the `layers.acceleration.force-enabled` preference and set it to true.
54+
3. Now restart Firefox, and it should look good!
55+
56+
#### X11 fix:
57+
1. Go to the `about:config` page
58+
2. Type `mozilla.widget.use-argb-visuals`
59+
3. Set it as a `boolean` and click on the add button
60+
4. Now restart Firefox, and it should look good!
61+
62+
## Development
63+
64+
If you wanna mess around the styles and change something, you might find these
65+
things useful.
66+
67+
To use the Inspector to debug the UI, open the developer tools (F12) on any
68+
page, go to options, check both of those:
69+
70+
- Enable browser chrome and add-on debugging toolboxes
71+
- Enable remote debugging
72+
73+
Now you can close those tools and press Ctrl+Alt+Shift+I to Inspect the browser
74+
UI.

install.sh

Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
#! /usr/bin/env bash
2+
3+
set -Eeo pipefail
4+
5+
readonly REPO_DIR="$(dirname "$(readlink -m "${0}")")"
6+
7+
MY_USERNAME="${SUDO_USER:-$(logname 2> /dev/null || echo "${USER}")}"
8+
MY_HOME=$(getent passwd "${MY_USERNAME}" | cut -d: -f6)
9+
10+
THEME_NAME="WhiteSur"
11+
12+
edit_firefox="false"
13+
14+
FIREFOX_SRC_DIR="${REPO_DIR}/src"
15+
FIREFOX_DIR_HOME="${MY_HOME}/.mozilla/firefox"
16+
FIREFOX_THEME_DIR="${MY_HOME}/.mozilla/firefox/firefox-themes"
17+
FIREFOX_FLATPAK_DIR_HOME="${MY_HOME}/.var/app/org.mozilla.firefox/.mozilla/firefox"
18+
FIREFOX_FLATPAK_THEME_DIR="${MY_HOME}/.var/app/org.mozilla.firefox/.mozilla/firefox/firefox-themes"
19+
FIREFOX_SNAP_DIR_HOME="${MY_HOME}/snap/firefox/common/.mozilla/firefox"
20+
FIREFOX_SNAP_THEME_DIR="${MY_HOME}/snap/firefox/common/.mozilla/firefox/firefox-themes"
21+
22+
export c_default="\033[0m"
23+
export c_blue="\033[1;34m"
24+
export c_magenta="\033[1;35m"
25+
export c_cyan="\033[1;36m"
26+
export c_green="\033[1;32m"
27+
export c_red="\033[1;31m"
28+
export c_yellow="\033[1;33m"
29+
30+
prompt() {
31+
case "${1}" in
32+
"-s")
33+
echo -e " ${c_green}${2}${c_default}" ;; # print success message
34+
"-e")
35+
echo -e " ${c_red}${2}${c_default}" ;; # print error message
36+
"-w")
37+
echo -e " ${c_yellow}${2}${c_default}" ;; # print warning message
38+
"-i")
39+
echo -e " ${c_cyan}${2}${c_default}" ;; # print info message
40+
esac
41+
}
42+
43+
has_command() {
44+
command -v "$1" &> /dev/null
45+
}
46+
47+
has_flatpak_app() {
48+
flatpak list --columns=application | grep "${1}" &> /dev/null || return 1
49+
}
50+
51+
has_snap_app() {
52+
snap list "${1}" &> /dev/null || return 1
53+
}
54+
55+
udoify_file() {
56+
if [[ -f "${1}" && "$(ls -ld "${1}" | awk '{print $3}')" != "${MY_USERNAME}" ]]; then
57+
schown "${MY_USERNAME}:" "${1}"
58+
fi
59+
}
60+
61+
helpify_title() {
62+
printf "${c_cyan}%s${c_blue}%s ${c_green}%s\n\n" "Usage: " "$0" "[OPTIONS...]"
63+
printf "${c_cyan}%s\n" "OPTIONS:"
64+
}
65+
66+
helpify() {
67+
printf " ${c_blue}%s ${c_green}%s\n ${c_magenta}%s. ${c_cyan}%s\n\n${c_default}" "${1}"
68+
}
69+
70+
usage() {
71+
helpify_title
72+
helpify "-f, --firefox" "[default|monterey]" "Install '${THEME_NAME}|Monterey' theme for Firefox and connect it to the current Firefox profiles" "Default is ${THEME_NAME}"
73+
helpify "-e, --edit-firefox" "" "Edit '${THEME_NAME}' theme for Firefox settings and also connect the theme to the current Firefox profiles" ""
74+
helpify "-h, --help" "" "Show this help" ""
75+
}
76+
77+
install_firefox_theme() {
78+
if has_snap_app firefox; then
79+
local TARGET_DIR="${FIREFOX_SNAP_THEME_DIR}"
80+
elif has_flatpak_app org.mozilla.firefox; then
81+
local TARGET_DIR="${FIREFOX_FLATPAK_THEME_DIR}"
82+
else
83+
local TARGET_DIR="${FIREFOX_THEME_DIR}"
84+
fi
85+
86+
local name=${1}
87+
88+
mkdir -p "${TARGET_DIR}"
89+
cp -rf "${FIREFOX_SRC_DIR}/${name}" "${TARGET_DIR}"
90+
[[ -f "${TARGET_DIR}"/customChrome.css ]] && mv "${TARGET_DIR}"/customChrome.css "${TARGET_DIR}"/customChrome.css.bak
91+
cp -rf "${FIREFOX_SRC_DIR}"/customChrome.css "${TARGET_DIR}"
92+
cp -rf "${FIREFOX_SRC_DIR}"/common/* "${TARGET_DIR}/${name}"
93+
[[ -f "${TARGET_DIR}"/userChrome.css ]] && mv "${TARGET_DIR}"/userChrome.css "${TARGET_DIR}"/userChrome.css.bak
94+
cp -rf "${FIREFOX_SRC_DIR}"/userChrome-"${name}".css "${TARGET_DIR}"/userChrome.css
95+
96+
config_firefox
97+
}
98+
99+
config_firefox() {
100+
if has_snap_app firefox; then
101+
local TARGET_DIR="${FIREFOX_SNAP_THEME_DIR}"
102+
local FIREFOX_DIR="${FIREFOX_SNAP_DIR_HOME}"
103+
elif has_flatpak_app org.mozilla.firefox; then
104+
local TARGET_DIR="${FIREFOX_FLATPAK_THEME_DIR}"
105+
local FIREFOX_DIR="${FIREFOX_FLATPAK_DIR_HOME}"
106+
else
107+
local TARGET_DIR="${FIREFOX_THEME_DIR}"
108+
local FIREFOX_DIR="${FIREFOX_DIR_HOME}"
109+
fi
110+
111+
killall "firefox" "firefox-bin" &> /dev/null || true
112+
113+
for d in "${FIREFOX_DIR}/"*"default"*; do
114+
if [[ -f "${d}/prefs.js" ]]; then
115+
rm -rf "${d}/chrome"
116+
ln -sf "${TARGET_DIR}" "${d}/chrome"
117+
udoify_file "${d}/prefs.js"
118+
echo "user_pref(\"toolkit.legacyUserProfileCustomizations.stylesheets\", true);" >> "${d}/prefs.js"
119+
echo "user_pref(\"browser.tabs.drawInTitlebar\", true);" >> "${d}/prefs.js"
120+
echo "user_pref(\"browser.uidensity\", 0);" >> "${d}/prefs.js"
121+
echo "user_pref(\"layers.acceleration.force-enabled\", true);" >> "${d}/prefs.js"
122+
echo "user_pref(\"mozilla.widget.use-argb-visuals\", true);" >> "${d}/prefs.js"
123+
fi
124+
done
125+
}
126+
127+
edit_firefox_theme_prefs() {
128+
if has_snap_app firefox; then
129+
local TARGET_DIR="${FIREFOX_SNAP_THEME_DIR}"
130+
elif has_flatpak_app org.mozilla.firefox; then
131+
local TARGET_DIR="${FIREFOX_FLATPAK_THEME_DIR}"
132+
else
133+
local TARGET_DIR="${FIREFOX_THEME_DIR}"
134+
fi
135+
136+
install_firefox_theme ; config_firefox
137+
${EDITOR:-nano} "${TARGET_DIR}/userChrome.css"
138+
${EDITOR:-nano} "${TARGET_DIR}/customChrome.css"
139+
}
140+
141+
remove_firefox_theme() {
142+
#rm -rf "${FIREFOX_DIR_HOME}/"*"default"*"/chrome"
143+
rm -rf "${FIREFOX_THEME_DIR}/${THEME_NAME}"
144+
[[ -f "${FIREFOX_THEME_DIR}"/customChrome.css ]] && rm -rf "${FIREFOX_THEME_DIR}"/customChrome.css
145+
[[ -f "${FIREFOX_THEME_DIR}"/userChrome.css ]] && rm -rf "${FIREFOX_THEME_DIR}"/userChrome.css
146+
#rm -rf "${FIREFOX_FLATPAK_DIR_HOME}/"*"default"*"/chrome"
147+
rm -rf "${FIREFOX_FLATPAK_THEME_DIR}/${THEME_NAME}"
148+
[[ -f "${FIREFOX_FLATPAK_THEME_DIR}"/customChrome.css ]] && rm -rf "${FIREFOX_FLATPAK_THEME_DIR}"/customChrome.css
149+
[[ -f "${FIREFOX_FLATPAK_THEME_DIR}"/userChrome.css ]] && rm -rf "${FIREFOX_FLATPAK_THEME_DIR}"/userChrome.css
150+
#rm -rf "${FIREFOX_SNAP_DIR_HOME}/"*"default"*"/chrome"
151+
rm -rf "${FIREFOX_SNAP_THEME_DIR}/${THEME_NAME}"
152+
[[ -f "${FIREFOX_SNAP_THEME_DIR}"/customChrome.css ]] && rm -rf "${FIREFOX_SNAP_THEME_DIR}"/customChrome.css
153+
[[ -f "${FIREFOX_SNAP_THEME_DIR}"/userChrome.css ]] && rm -rf "${FIREFOX_SNAP_THEME_DIR}"/userChrome.css
154+
}
155+
156+
echo
157+
158+
while [[ $# -gt 0 ]]; do
159+
# Don't show any dialog here. Let this loop checks for errors or shows help
160+
# We can only show dialogs when there's no error and no -r parameter
161+
#
162+
# * shift for parameters that have no value
163+
# * shift 2 for parameter that have a value
164+
#
165+
# Please don't exit any error here if possible. Let it show all error warnings
166+
# at once
167+
168+
case "${1}" in
169+
# Parameters that don't require value
170+
-r|--remove|--revert)
171+
uninstall='true'; shift ;;
172+
-h|--help)
173+
need_help="true"; shift ;;
174+
-f|--firefox|-e|--edit-firefox)
175+
case "${1}" in
176+
-f|--firefox)
177+
firefox="true" ;;
178+
-e|--edit-firefox)
179+
edit_firefox="true" ;;
180+
esac
181+
182+
for variant in "${@}"; do
183+
case "${variant}" in
184+
default)
185+
shift 1
186+
;;
187+
monterey)
188+
monterey="true"
189+
THEME_NAME="Monterey"
190+
shift 1
191+
;;
192+
esac
193+
done
194+
195+
if ! has_command firefox && ! has_flatpak_app org.mozilla.firefox && ! has_snap_app firefox; then
196+
prompt -e "'${1}' ERROR: There's no Firefox installed in your system"
197+
has_any_error="true"
198+
elif [[ ! -d "${FIREFOX_DIR_HOME}" && ! -d "${FIREFOX_FLATPAK_DIR_HOME}" && ! -d "${FIREFOX_SNAP_DIR_HOME}" ]]; then
199+
prompt -e "'${1}' ERROR: Firefox is installed but not yet initialized."
200+
prompt -w "'${1}': Don't forget to close it after you run/initialize it"
201+
elif pidof "firefox" &> /dev/null || pidof "firefox-bin" &> /dev/null; then
202+
prompt -e "'${1}' ERROR: Firefox is running, please close it"
203+
has_any_error="true"
204+
fi; shift ;;
205+
*)
206+
prompt -e "ERROR: Unrecognized tweak option '${1}'."
207+
has_any_error="true"; shift ;;
208+
esac
209+
done
210+
211+
if [[ "${uninstall}" == 'true' ]]; then
212+
prompt -i "Removing '${THEME_NAME}' Firefox theme..."
213+
remove_firefox_theme
214+
prompt -s "Done! '${THEME_NAME}' Firefox theme has been removed."; echo
215+
else
216+
prompt -i "Installing '${THEME_NAME}' Firefox theme..."
217+
install_firefox_theme "${name:-${THEME_NAME}}"
218+
prompt -s "Done! '${THEME_NAME}' Firefox theme has been installed."; echo
219+
220+
if [[ "${edit_firefox}" == 'true' ]]; then
221+
prompt -i "Editing '${THEME_NAME}' Firefox theme preferences..."
222+
edit_firefox_theme_prefs
223+
prompt -s "Done! '${THEME_NAME}' Firefox theme preferences has been edited."; echo
224+
fi
225+
226+
prompt -w "FIREFOX: Please go to [Firefox menu] > [Customize...], and customize your Firefox to make it work. Move your 'new tab' button to the titlebar instead of tab-switcher."
227+
prompt -i "FIREFOX: Anyways, you can also edit 'userChrome.css' and 'customChrome.css' later in your Firefox profile directory."
228+
echo
229+
fi

0 commit comments

Comments
 (0)