Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions librewolf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# LibreWolf

Themes the LibreWolf browser chrome (toolbar, tabs, URL bar, menus, sidebar) and
the built-in `about:` pages with the Noctalia palette, using the same native
`userChrome.css` / `userContent.css` mechanism as Firefox. No extension required.

LibreWolf is a Firefox fork, so this template is the same CSS as the
[`firefox/`](../firefox/) template, adapted to LibreWolf's profile locations.

## What it themes

- **Browser chrome** (`librewolf-userChrome.css`): tab bar, navigation toolbar,
URL bar and its results, bookmarks bar, sidebar, find bar, menus/panels,
context menus, dialogs, autocomplete popups, download panel, select dropdowns.
- **Content pages** (`librewolf-userContent.css`): `about:newtab` / `about:home`,
`about:preferences` and its sub-dialogs, `about:addons`, `about:logins`,
`about:protections`, `about:config`, `about:profiles`, and more.

Both dark and light variants are generated; the browser switches automatically
via `prefers-color-scheme`.

## Setup

When the Noctalia theming script runs, it automatically:

1. Finds LibreWolf profiles by locating their `prefs.js` files, in:
- `~/.librewolf` (regular installs)
- `~/.config/librewolf` (new XDG layout — profiles may be one level deeper,
e.g. `~/.config/librewolf/librewolf/<profile>/`)
- `~/.var/app/io.gitlab.librewolf-community/.librewolf` (Flatpak)
- `~/snap/librewolf/common/.librewolf` (Snap)
2. Creates each profile's `chrome/` directory when necessary.
3. Adds the Noctalia imports to `userChrome.css` and `userContent.css`.
4. Enables the required preferences through the profile's `user.js`:
- `toolkit.legacyUserProfileCustomizations.stylesheets` — load `userChrome.css`
- `svg.context-properties.content.enabled` — colored icons on `about:` pages
- `devtools.chrome.enabled` — browser chrome debugging

No manual changes in `about:config` are required.

## Set website appearance

Open **Settings → Appearance** and set **Website Appearance** to **Auto** so
websites and the browser follow the color scheme generated by Noctalia.

## Apply changes

**Restart LibreWolf** after the initial setup. A restart may also be required
after color changes for the updated theme to appear.

## Troubleshooting

- **Theme not appearing:** make sure the template is enabled in Noctalia,
re-apply your theme, then restart LibreWolf.
- **Some colors look wrong:** extensions or existing `userChrome.css` content
can override template colors. Check `chrome/userChrome.css` for other imports.
- **Only some profiles are themed:** the hook updates every profile it finds
under the paths above. Profiles stored in a custom location are not touched.

## Removing the theme

Disable the template in Noctalia, delete the
`@import "…librewolf-userChrome.css";` / `@import "…librewolf-userContent.css";`
lines from each profile's `userChrome.css` / `userContent.css`, and remove the
preferences added by this template from `user.js` (or delete those files if you
never customized them).

## Files

| File | Purpose |
| --- | --- |
| `template.toml` | Noctalia manifest (renders both CSS files, runs `apply.sh`) |
| `apply.sh` | Finds profiles, wires up imports and preferences (idempotent) |
| `librewolf-userChrome.css` | Browser chrome theme |
| `librewolf-userContent.css` | `about:` pages theme |
Binary file added librewolf/about-preferences-screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
76 changes: 76 additions & 0 deletions librewolf/apply.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/usr/bin/env bash
set -euo pipefail

cache_dir="${XDG_CACHE_HOME:-$HOME/.cache}"
css_chrome="$cache_dir/noctalia/librewolf/librewolf-userChrome.css"
css_content="$cache_dir/noctalia/librewolf/librewolf-userContent.css"
line_chrome="@import \"$css_chrome\";"
line_content="@import \"$css_content\";"

write_if_changed() {
local target="$1" tmp="$2"
if ! cmp -s "$target" "$tmp"; then
cat "$tmp" >"$target"
fi
rm -f "$tmp"
}

# LibreWolf keeps one prefs.js per profile, under one of these roots:
# ~/.librewolf (regular installs)
# $XDG_CONFIG_HOME/librewolf (new XDG layout; profiles may
# sit directly under it or one
# level deeper under librewolf/)
# ~/.var/app/io.gitlab.librewolf-community/... (Flatpak)
# ~/snap/librewolf/common/... (Snap)
roots=()
for root in \
"${HOME}/.librewolf" \
"${XDG_CONFIG_HOME:-$HOME/.config}/librewolf" \
"${HOME}/.var/app/io.gitlab.librewolf-community/.librewolf" \
"${HOME}/snap/librewolf/common/.librewolf"
do
[ -d "$root" ] && roots+=("$root")
done

if [ "${#roots[@]}" -gt 0 ]; then
find "${roots[@]}" -mindepth 1 -maxdepth 3 -type f -name "prefs.js" -print0 2>/dev/null |
while IFS= read -r -d '' prefs_file; do
profile_dir=$(dirname "$prefs_file")
chrome_dir="$profile_dir/chrome"
user_chrome="$chrome_dir/userChrome.css"
user_content="$chrome_dir/userContent.css"
user_js="$profile_dir/user.js"

mkdir -p "$chrome_dir"
touch "$user_chrome" "$user_content" "$user_js"

tmp_chrome="$(mktemp "${user_chrome}.tmp.XXXXXX")"
sed '/noctalia\/librewolf\/librewolf-userChrome\.css/d' "$user_chrome" >"$tmp_chrome"
if ! grep -Fq "$line_chrome" "$tmp_chrome"; then
[ -s "$tmp_chrome" ] && [ -n "$(tail -c1 "$tmp_chrome")" ] && echo >>"$tmp_chrome"
printf '%s\n' "$line_chrome" >>"$tmp_chrome"
fi
write_if_changed "$user_chrome" "$tmp_chrome"

tmp_content="$(mktemp "${user_content}.tmp.XXXXXX")"
sed '/noctalia\/librewolf\/librewolf-userContent\.css/d' "$user_content" >"$tmp_content"
if ! grep -Fq "$line_content" "$tmp_content"; then
[ -s "$tmp_content" ] && [ -n "$(tail -c1 "$tmp_content")" ] && echo >>"$tmp_content"
printf '%s\n' "$line_content" >>"$tmp_content"
fi
write_if_changed "$user_content" "$tmp_content"

tmp_js="$(mktemp "${user_js}.tmp.XXXXXX")"
sed \
-e '/toolkit\.legacyUserProfileCustomizations\.stylesheets/d' \
-e '/svg\.context-properties\.content\.enabled/d' \
-e '/devtools\.chrome\.enabled/d' \
"$user_js" >"$tmp_js"
[ -s "$tmp_js" ] && [ -n "$(tail -c1 "$tmp_js")" ] && echo >>"$tmp_js"
printf '%s\n' \
'user_pref("toolkit.legacyUserProfileCustomizations.stylesheets", true);' \
'user_pref("svg.context-properties.content.enabled", true);' \
'user_pref("devtools.chrome.enabled", true);' >>"$tmp_js"
write_if_changed "$user_js" "$tmp_js"
done
fi
Loading