Compare commits

..
Author SHA1 Message Date
5c6d16ed1a 0.4.2: packaging (arch-bin PKGBUILD, Nix)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-12-03 10:41:26 -06:00
82a5adf7c7 0.4.2: release notes, version bump
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-12-03 10:35:59 -06:00
297034eb0d Discord: only send icons Discord can show (no ICO/SVG), fall back to og:image
discord.com only has /assets/favicon.ico, which Discord draws as "?".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-12-03 10:35:45 -06:00
af09e4d359 Follow desktop colours live: watch scheme.json and kdeglobals, take Caelestia's mode
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-12-03 10:06:15 -06:00
44a83e87b5 Move Astar Hub links to astar76.com
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-12-02 16:26:01 -06:00
d529088b6b docs: Astar Hub moved to astar76sites.parore-gila.ts.net
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-12-02 12:15:11 -06:00
d71fed68b9 docs: Astar Hub moved to astar76sites.tail7c4f5e.ts.net
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-12-02 12:07:39 -06:00
19 changed files with 136 additions and 52 deletions

View file

@ -37,7 +37,7 @@ Never modify: `~/Documents/Apps/Nacre` (the original Python Nacre, reference onl
## 2. Facts ## 2. Facts
- **Engine**: WebKitGTK 6.0 (`webkit6` crate, `=0.6.1`) in a GTK 4 window; egui draws the chrome in a transparent `Gtk.GLArea` over the web views (D-033, D-035). WebKit tuning data and the engine test: `docs/engine/engine-comparison.md`, `docs/engine/tune/`. The Servo removal inventory (history): `docs/engine/servo-removal.md`. Pages' network work happens in the web process extension `webext/`. - **Engine**: WebKitGTK 6.0 (`webkit6` crate, `=0.6.1`) in a GTK 4 window; egui draws the chrome in a transparent `Gtk.GLArea` over the web views (D-033, D-035). WebKit tuning data and the engine test: `docs/engine/engine-comparison.md`, `docs/engine/tune/`. The Servo removal inventory (history): `docs/engine/servo-removal.md`. Pages' network work happens in the web process extension `webext/`.
- Cargo package `nacre` 0.4.1, edition 2024, Rust ≥ 1.88. No Servo, vendored crates or patched engine any more; builds take minutes (~2–4 min release), not hours. - Cargo package `nacre` 0.4.2, edition 2024, Rust ≥ 1.88. No Servo, vendored crates or patched engine any more; builds take minutes (~2–4 min release), not hours.
- Status: builds, `cargo test` green, hidden smokes pass; features still to re-verify on WebKit are marked in `docs/FEATURES.md`. - Status: builds, `cargo test` green, hidden smokes pass; features still to re-verify on WebKit are marked in `docs/FEATURES.md`.
- User rules: function first; plain egui UI until everything works; the Material You redesign comes afterwards (see `docs/UI-BRIEF.md`); nothing from the original is dropped silently (engine limits are shown as unavailable, see DESIGN.md "Engine limits"); never connect to Tor or proxies in tests. - User rules: function first; plain egui UI until everything works; the Material You redesign comes afterwards (see `docs/UI-BRIEF.md`); nothing from the original is dropped silently (engine limits are shown as unavailable, see DESIGN.md "Engine limits"); never connect to Tor or proxies in tests.
- Known gaps and things to check at the first build: `docs/REVIEW.md`. Feature list with file and review state: `docs/FEATURES.md`. - Known gaps and things to check at the first build: `docs/REVIEW.md`. Feature list with file and review state: `docs/FEATURES.md`.

4
Cargo.lock generated
View file

@ -1899,7 +1899,7 @@ dependencies = [
[[package]] [[package]]
name = "nacre" name = "nacre"
version = "0.4.1" version = "0.4.2"
dependencies = [ dependencies = [
"adblock", "adblock",
"arboard", "arboard",
@ -1935,7 +1935,7 @@ dependencies = [
[[package]] [[package]]
name = "nacre-webext" name = "nacre-webext"
version = "0.4.1" version = "0.4.2"
dependencies = [ dependencies = [
"glib-sys", "glib-sys",
"gobject-sys", "gobject-sys",

View file

@ -1,6 +1,6 @@
[package] [package]
name = "nacre" name = "nacre"
version = "0.4.1" version = "0.4.2"
edition = "2024" edition = "2024"
rust-version = "1.88" rust-version = "1.88"
description = "Nacre, a web browser built on WebKitGTK" description = "Nacre, a web browser built on WebKitGTK"

View file

@ -15,7 +15,7 @@ Linux only: WebKitGTK has no Windows or macOS build.
## Install ## Install
Downloads are on the [Releases page](https://archlinux.tail7c4f5e.ts.net/git/astar76/Nacre/releases). Check them Downloads are on the [Releases page](https://astar76.com/git/astar76/Nacre/releases). Check them
against `SHA256SUMS-<version>`. against `SHA256SUMS-<version>`.
- **Arch Linux:** `sudo pacman -U Nacre-<version>-arch-x86_64.pkg.tar.zst` (package `nacre-bin`; remove it with - **Arch Linux:** `sudo pacman -U Nacre-<version>-arch-x86_64.pkg.tar.zst` (package `nacre-bin`; remove it with
@ -23,7 +23,7 @@ against `SHA256SUMS-<version>`.
To build from this checkout instead: `./install.sh` (package `nacre`). To build from this checkout instead: `./install.sh` (package `nacre`).
- **Debian, Ubuntu and other apt systems:** `sudo apt install ./Nacre-<version>-amd64.deb`. Needs WebKitGTK 6.0 and - **Debian, Ubuntu and other apt systems:** `sudo apt install ./Nacre-<version>-amd64.deb`. Needs WebKitGTK 6.0 and
a glibc as new as the one named in the package (recent releases only). a glibc as new as the one named in the package (recent releases only).
- **Nix:** `nix profile install git+https://archlinux.tail7c4f5e.ts.net/git/astar76/Nacre` (flake), or - **Nix:** `nix profile install git+https://astar76.com/git/astar76/Nacre` (flake), or
`callPackage ./packaging/nix { }`. `callPackage ./packaging/nix { }`.
- **Any distribution:** unpack `Nacre-<version>-Linux-x86_64.tar.gz` and run `sh install.sh` (your home, `~/.local`, - **Any distribution:** unpack `Nacre-<version>-Linux-x86_64.tar.gz` and run `sh install.sh` (your home, `~/.local`,
no root) or `sh install.sh --system` (`/usr/local`). `sh uninstall.sh` removes it; `--purge` also deletes your no root) or `sh install.sh --system` (`/usr/local`). `sh uninstall.sh` removes it; `--purge` also deletes your

View file

@ -575,6 +575,12 @@ Later: S010 list: user checks the Discord icon with their own client (the Discor
- Not done: named profiles, a master-password vault, the old reading list, settings and cookies of the old Nacre; the native file dialog; the user's real data (they press Import). - Not done: named profiles, a master-password vault, the old reading list, settings and cookies of the old Nacre; the native file dialog; the user's real data (they press Import).
- Later: the binary logs a CRITICAL about the build folder's tests/smoke/pages (compiled-in path) at start; `install.sh` has no lock against running twice and wipes `target/` even while a cargo build uses it. - Later: the binary logs a CRITICAL about the build folder's tests/smoke/pages (compiled-in path) at start; `install.sh` has no lock against running twice and wipes `target/` even while a cargo build uses it.
## Desktop colours live (2026-12-03)
- Nacre follows Caelestia's `scheme.json` and KDE's `kdeglobals` live: the tick checks their mtimes (`theme::file_stamps`) about every second; on a change it re-reads the system accent and dark mode and restyles every window (no restart).
- "System" theme mode now takes Caelestia's `mode` (dark/light) first, then GTK, then GNOME (`theme::system_dark`).
- Verified: `cargo test` 103 + webext 1; hidden smoke on a throwaway home: scheme.json rewritten from purple/dark to green/light mid-run, the new tab page and chrome went green and light (before/after shots read).
- Not done: GNOME portal `accent-color` live watch.
## Later ## Later
- A link followed inside a frame still goes through the tab's navigation policy (WebKit's GTK API has no frame info; S050). - A link followed inside a frame still goes through the tab's navigation policy (WebKit's GTK API has no frame info; S050).
- file:// media outside the XDG user folders doesn't play (WebKit sandbox, D-043). - file:// media outside the XDG user folders doesn't play (WebKit sandbox, D-043).
@ -583,12 +589,12 @@ Later: S010 list: user checks the Discord icon with their own client (the Discor
- Bookmark flyout stays open after switching tabs and shows the old page's bookmark (S006 keys.txt shot). - Bookmark flyout stays open after switching tabs and shows the old page's bookmark (S006 keys.txt shot).
- Wikipedia search widget ignores the selftest's Enter (plain forms submit); check with a real keyboard (S006). - Wikipedia search widget ignores the selftest's Enter (plain forms submit); check with a real keyboard (S006).
- YouTube's result list lays out at zero size; CSS mask-image icons paint as squares (Servo layout, S006). - YouTube's result list lays out at zero size; CSS mask-image icons paint as squares (Servo layout, S006).
- System accent: watch caelestia scheme.json / the portal `accent-color` and restyle live (R1-11). - System accent: the GNOME portal `accent-color` isn't watched live (only Caelestia's scheme.json and kdeglobals).
- Reader mode, split view, translate, real gamepad rumble (D-002: not planned for now). - Reader mode, split view, translate, real gamepad rumble (D-002: not planned for now).
- AppImage / tar.gz release (D-001, D-054). - AppImage / tar.gz release (D-001, D-054).
- Shortcut icons: a favicon cache by host (today only open tabs' favicons show). - Shortcut icons: a favicon cache by host (today only open tabs' favicons show).
- Interface size above ~110 % on a narrow (772 px) window clips wide segmented rows at the right (R1-21 visible run). - Interface size above ~110 % on a narrow (772 px) window clips wide segmented rows at the right (R1-21 visible run).
- A test run (fresh profile, internet) moves ~200 KB before the first page and looks up the update host - A test run (fresh profile, internet) moves ~200 KB before the first page and looks up the update host
(archlinux.tail7c4f5e.ts.net); find out which background fetch it is, maybe skip it in smoke runs (S007). (astar76.com); find out which background fetch it is, maybe skip it in smoke runs (S007).
- Downloads at addresses that give no hint (no extension, no "download"-like path) aren't probed, so they aren't - Downloads at addresses that give no hint (no extension, no "download"-like path) aren't probed, so they aren't
treated as downloads (what Servo then shows wasn't checked) (S007). treated as downloads (what Servo then shows wasn't checked) (S007).

9
docs/releases/0.4.2.md Normal file
View file

@ -0,0 +1,9 @@
# Nacre 0.4.2
- **Follows desktop colours live:** with Caelestia (or KDE colours), Nacre changes colour as soon as the wallpaper or
scheme changes, light or dark included. No restart.
- **Discord Rich Presence icons:** sites whose only icon is an `.ico` or `.svg` (discord.com, for example) no longer
show a "?"; Nacre sends a PNG/JPEG icon or the page's preview image instead.
- Astar Hub links (update check, packages) moved to astar76.com.
Linux x86_64 only (WebKitGTK has no Windows build).

View file

@ -1,8 +1,8 @@
pkgbase = nacre-bin pkgbase = nacre-bin
pkgdesc = A web browser built on WebKitGTK pkgdesc = A web browser built on WebKitGTK
pkgver = 0.4.1 pkgver = 0.4.2
pkgrel = 1 pkgrel = 1
url = https://archlinux.tail7c4f5e.ts.net/git/astar76/Nacre url = https://astar76.com/git/astar76/Nacre
arch = x86_64 arch = x86_64
license = MPL-2.0 license = MPL-2.0
depends = glibc>=2.43 depends = glibc>=2.43
@ -29,7 +29,7 @@ pkgbase = nacre-bin
conflicts = nacre conflicts = nacre
options = !strip options = !strip
options = !debug options = !debug
source = Nacre-0.4.1-Linux-x86_64.tar.gz::https://archlinux.tail7c4f5e.ts.net/git/astar76/Nacre/releases/download/v0.4.1/Nacre-0.4.1-Linux-x86_64.tar.gz source = Nacre-0.4.2-Linux-x86_64.tar.gz::https://astar76.com/git/astar76/Nacre/releases/download/v0.4.2/Nacre-0.4.2-Linux-x86_64.tar.gz
sha256sums = 35902a2a539a53320814e9fd4ff670c118153fd8eaa6c788ef2dcf37bdcb2cff sha256sums = c4865f30221bddd62fbb812781cdfe5974c615bebaf73b215e64e3a6867ab97a
pkgname = nacre-bin pkgname = nacre-bin

View file

@ -2,11 +2,11 @@
# Built by tools/package.sh from the release tar.gz (TARBALL=file://… for an offline build); it keeps pkgver, # Built by tools/package.sh from the release tar.gz (TARBALL=file://… for an offline build); it keeps pkgver,
# sha256sums and the glibc floor current. # sha256sums and the glibc floor current.
pkgname=nacre-bin pkgname=nacre-bin
pkgver=0.4.1 pkgver=0.4.2
pkgrel=1 pkgrel=1
pkgdesc='A web browser built on WebKitGTK' pkgdesc='A web browser built on WebKitGTK'
arch=('x86_64') arch=('x86_64')
url='https://archlinux.tail7c4f5e.ts.net/git/astar76/Nacre' url='https://astar76.com/git/astar76/Nacre'
license=('MPL-2.0') license=('MPL-2.0')
depends=('glibc>=2.43' 'gcc-libs' 'webkitgtk-6.0' 'gtk4' 'libsoup3' 'libepoxy' 'gstreamer' 'gst-plugins-base' 'gst-plugins-good' 'gst-plugins-bad' 'gst-libav' 'dbus' 'pam' 'hicolor-icon-theme' 'xdg-utils') depends=('glibc>=2.43' 'gcc-libs' 'webkitgtk-6.0' 'gtk4' 'libsoup3' 'libepoxy' 'gstreamer' 'gst-plugins-base' 'gst-plugins-good' 'gst-plugins-bad' 'gst-libav' 'dbus' 'pam' 'hicolor-icon-theme' 'xdg-utils')
optdepends=( optdepends=(
@ -20,7 +20,7 @@ provides=('nacre')
conflicts=('nacre') conflicts=('nacre')
options=('!strip' '!debug') options=('!strip' '!debug')
source=("Nacre-$pkgver-Linux-x86_64.tar.gz::${TARBALL:-$url/releases/download/v$pkgver/Nacre-$pkgver-Linux-x86_64.tar.gz}") source=("Nacre-$pkgver-Linux-x86_64.tar.gz::${TARBALL:-$url/releases/download/v$pkgver/Nacre-$pkgver-Linux-x86_64.tar.gz}")
sha256sums=('35902a2a539a53320814e9fd4ff670c118153fd8eaa6c788ef2dcf37bdcb2cff') sha256sums=('c4865f30221bddd62fbb812781cdfe5974c615bebaf73b215e64e3a6867ab97a')
package() { package() {
cd "$srcdir/nacre-$pkgver" cd "$srcdir/nacre-$pkgver"

View file

@ -4,7 +4,7 @@ pkgver=0.4.0
pkgrel=1 pkgrel=1
pkgdesc="A web browser built on WebKitGTK" pkgdesc="A web browser built on WebKitGTK"
arch=(x86_64) arch=(x86_64)
url="https://archlinux.tail7c4f5e.ts.net/git/astar76/Nacre" url="https://astar76.com/git/astar76/Nacre"
license=(MPL-2.0) license=(MPL-2.0)
depends=(webkitgtk-6.0 gtk4 gst-plugins-base gst-plugins-good gst-plugins-bad gst-libav dbus pam glibc libgcc libepoxy libsoup3 gstreamer hicolor-icon-theme xdg-utils) depends=(webkitgtk-6.0 gtk4 gst-plugins-base gst-plugins-good gst-plugins-bad gst-libav dbus pam glibc libgcc libepoxy libsoup3 gstreamer hicolor-icon-theme xdg-utils)
makedepends=(cargo git pkgconf) makedepends=(cargo git pkgconf)

View file

@ -4,10 +4,10 @@
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "nacre"; pname = "nacre";
version = "0.4.1"; version = "0.4.2";
src = fetchurl { src = fetchurl {
url = "https://archlinux.tail7c4f5e.ts.net/git/astar76/Nacre/releases/download/v${version}/Nacre-${version}-Linux-x86_64.tar.gz"; url = "https://astar76.com/git/astar76/Nacre/releases/download/v${version}/Nacre-${version}-Linux-x86_64.tar.gz";
hash = "sha256-NZAqKlOaUzIIFOn9T/ZwwRgVP9jqpseI7y3PN73LLP8="; hash = "sha256-xIZfMCIb3dYvu4Engc3+WXTGFb669zshXmTjpoZ6uXo=";
}; };
nativeBuildInputs = [ autoPatchelfHook makeWrapper wrapGAppsHook4 ]; nativeBuildInputs = [ autoPatchelfHook makeWrapper wrapGAppsHook4 ];
buildInputs = [ webkitgtk_6_0 gtk4 libsoup_3 libepoxy pam dbus glib-networking gst_all_1.gstreamer gst_all_1.gst-plugins-base gst_all_1.gst-plugins-good gst_all_1.gst-plugins-bad gst_all_1.gst-libav stdenv.cc.cc.lib ]; buildInputs = [ webkitgtk_6_0 gtk4 libsoup_3 libepoxy pam dbus glib-networking gst_all_1.gstreamer gst_all_1.gst-plugins-base gst_all_1.gst-plugins-good gst_all_1.gst-plugins-bad gst_all_1.gst-libav stdenv.cc.cc.lib ];
@ -24,7 +24,7 @@ stdenv.mkDerivation rec {
meta = { meta = {
description = "A web browser built on WebKitGTK"; description = "A web browser built on WebKitGTK";
homepage = "https://archlinux.tail7c4f5e.ts.net/git/astar76/Nacre"; homepage = "https://astar76.com/git/astar76/Nacre";
license = lib.licenses.mpl20; license = lib.licenses.mpl20;
platforms = [ "x86_64-linux" ]; platforms = [ "x86_64-linux" ];
mainProgram = "nacre"; mainProgram = "nacre";

View file

@ -1672,7 +1672,8 @@ impl App {
"ready" => {}, "ready" => {},
"meta" => { "meta" => {
let color = crate::theme::parse_css_color(&s(&data, "theme_color")); let color = crate::theme::parse_css_color(&s(&data, "theme_color"));
let icon = data.get("icons").and_then(|v| v.as_array()).and_then(|a| a.first()).map(|i| s(i, "href")).unwrap_or_default(); let icons: Vec<String> = data.get("icons").and_then(|v| v.as_array()).map(|a| a.iter().map(|i| s(i, "href")).collect()).unwrap_or_default();
let icon = icons.first().cloned().unwrap_or_default();
let changed; let changed;
{ {
let tab = &mut self.windows.get_mut(&w).expect("found").tabs[i]; let tab = &mut self.windows.get_mut(&w).expect("found").tabs[i];
@ -1680,6 +1681,7 @@ impl App {
tab.theme_color = color; tab.theme_color = color;
tab.site_name = s(&data, "site_name"); tab.site_name = s(&data, "site_name");
tab.page_image = s(&data, "image"); tab.page_image = s(&data, "image");
tab.rpc_icon = icons.iter().find(|i| crate::discord::usable_image(i)).cloned().unwrap_or_default();
tab.manifest = s(&data, "manifest"); tab.manifest = s(&data, "manifest");
if !icon.is_empty() { if !icon.is_empty() {
tab.favicon_url = icon; tab.favicon_url = icon;
@ -2242,14 +2244,14 @@ impl App {
} }
let mut state = state.clone(); let mut state = state.clone();
state.position = state.position_at(*received); state.position = state.position_at(*received);
activity = crate::discord::media_activity(&settings, &url, &tab.title, &tab.favicon_url, &state, tab.id, &mut self.presence_started); activity = crate::discord::media_activity(&settings, &url, &tab.title, &[&tab.rpc_icon, &tab.page_image], &state, tab.id, &mut self.presence_started);
} }
if activity.is_none() if activity.is_none()
&& let Some(win) = self.current_window().and_then(|w| self.windows.get(&w)) && let Some(win) = self.current_window().and_then(|w| self.windows.get(&w))
&& let Some(tab) = win.tab() && let Some(tab) = win.tab()
&& tab.page.is_none() && tab.page.is_none()
&& let Ok(url) = Url::parse(&tab.url) && let Ok(url) = Url::parse(&tab.url)
&& let Some(act) = crate::discord::browse_activity(&settings, &url, &tab.title, &tab.site_name, &tab.page_image, &tab.favicon_url, tab.arrived_ms as i64) && let Some(act) = crate::discord::browse_activity(&settings, &url, &tab.title, &tab.site_name, &tab.page_image, &tab.rpc_icon, tab.arrived_ms as i64)
{ {
activity = Some((act, settings.client_id.clone())); activity = Some((act, settings.client_id.clone()));
} }

View file

@ -143,7 +143,7 @@ pub struct Shared {
pub vpn_status: RefCell<VpnStatus>, pub vpn_status: RefCell<VpnStatus>,
pub speller: RefCell<Option<Speller>>, pub speller: RefCell<Option<Speller>>,
pub spell_status: RefCell<String>, pub spell_status: RefCell<String>,
pub system_accent: Option<egui::Color32>, pub system_accent: Cell<Option<egui::Color32>>,
pub user_agent: RefCell<String>, pub user_agent: RefCell<String>,
pub devtools: RefCell<Option<(u16, String)>>, pub devtools: RefCell<Option<(u16, String)>>,
pub update: RefCell<Option<crate::updates::Release>>, pub update: RefCell<Option<crate::updates::Release>>,
@ -241,6 +241,8 @@ pub struct App {
/// A quit or window close waiting for the pages' `beforeunload`. /// A quit or window close waiting for the pages' `beforeunload`.
pub shutdown: Option<Shutdown>, pub shutdown: Option<Shutdown>,
last_tick: Instant, last_tick: Instant,
/// Modification times of the desktop's colour files (`theme::desktop_files`), to follow them live.
desktop_stamps: Vec<Option<std::time::SystemTime>>,
last_save: Instant, last_save: Instant,
last_slow: Instant, last_slow: Instant,
/// Sealed cookies (D-037), `None` when they are kept for the run only. /// Sealed cookies (D-037), `None` when they are kept for the run only.
@ -313,7 +315,7 @@ impl App {
vpn_status: RefCell::new(VpnStatus::Off), vpn_status: RefCell::new(VpnStatus::Off),
speller: RefCell::new(None), speller: RefCell::new(None),
spell_status: RefCell::new(String::new()), spell_status: RefCell::new(String::new()),
system_accent: theme::system_accent(), system_accent: Cell::new(theme::system_accent()),
user_agent: RefCell::new(String::new()), user_agent: RefCell::new(String::new()),
devtools: RefCell::new(None), devtools: RefCell::new(None),
update: RefCell::new(None), update: RefCell::new(None),
@ -368,6 +370,7 @@ impl App {
exiting: false, exiting: false,
shutdown: None, shutdown: None,
last_tick: Instant::now(), last_tick: Instant::now(),
desktop_stamps: theme::file_stamps(&theme::desktop_files()),
last_save: Instant::now(), last_save: Instant::now(),
last_slow: Instant::now() - Duration::from_secs(3600), last_slow: Instant::now() - Duration::from_secs(3600),
cookies: None, cookies: None,
@ -1277,6 +1280,14 @@ impl App {
if self.shared.toasts.borrow().len() != before { if self.shared.toasts.borrow().len() != before {
self.redraw_all(); self.redraw_all();
} }
// A new wallpaper, scheme or mode on the desktop (Caelestia's scheme.json, kdeglobals).
let stamps = theme::file_stamps(&theme::desktop_files());
if stamps != self.desktop_stamps {
self.desktop_stamps = stamps;
self.shared.system_accent.set(theme::system_accent());
*self.shared.system_dark.borrow_mut() = theme::system_dark(gtk_dark());
self.restyle_all();
}
// Loading spinners and media position need regular redraws. // Loading spinners and media position need regular redraws.
let busy: Vec<WindowId> = self.windows.iter().filter(|(_, w)| w.tabs.iter().any(|t| t.loading() || t.audible())).map(|(id, _)| *id).collect(); let busy: Vec<WindowId> = self.windows.iter().filter(|(_, w)| w.tabs.iter().any(|t| t.loading() || t.audible())).map(|(id, _)| *id).collect();
for w in busy { for w in busy {
@ -1618,7 +1629,7 @@ impl App {
let settings = self.shared.settings.borrow(); let settings = self.shared.settings.borrow();
let dark = theme::is_dark(&settings, *self.shared.system_dark.borrow()); let dark = theme::is_dark(&settings, *self.shared.system_dark.borrow());
let site = win.tab().and_then(Tab::site_colour); let site = win.tab().and_then(Tab::site_colour);
let palette = theme::Palette::new(theme::seed(&settings, site, self.shared.system_accent), dark, &settings.theme.variant, settings.theme.contrast); let palette = theme::Palette::new(theme::seed(&settings, site, self.shared.system_accent.get()), dark, &settings.theme.variant, settings.theme.contrast);
let ctx = win.ctx(); let ctx = win.ctx();
theme::apply(&ctx, &palette, &settings); theme::apply(&ctx, &palette, &settings);
// Always, so going back to 100 % takes effect too. // Always, so going back to 100 % takes effect too.

View file

@ -111,17 +111,17 @@ fn https_short(url: &str) -> bool {
url.starts_with("https://") && url.len() <= 256 url.starts_with("https://") && url.len() <= 256
} }
/// Image for the activity's large icon: the first of `images` Discord can fetch (short https URL), /// An image Discord can show: a short https URL that isn't ICO or SVG (Discord draws those as "?").
/// else the page origin's /favicon.ico (data:/http:/long favicon URLs are unusable; no third-party pub fn usable_image(url: &str) -> bool {
/// service, so no visited host leaks beyond Discord). Empty for pages without a host. let path = url.split(['?', '#']).next().unwrap_or("").to_ascii_lowercase();
fn icon_url(images: &[&str], page: &Url) -> String { https_short(url) && !path.ends_with(".ico") && !path.ends_with(".svg")
if let Some(img) = images.iter().find(|i| https_short(i)) { }
return (*img).to_owned();
} /// Image for the activity's large icon: the first of `images` Discord can show, else none, so
match page.host_str() { /// Discord shows the application's own icon (no third-party favicon service, so no visited host
Some(host) if matches!(page.scheme(), "http" | "https") => format!("https://{host}/favicon.ico"), /// leaks beyond Discord).
_ => String::new(), fn icon_url(images: &[&str]) -> String {
} images.iter().find(|i| usable_image(i)).map(|i| (*i).to_owned()).unwrap_or_default()
} }
/// Options that Discord clients may refuse; the worker turns them off when it is told so. /// Options that Discord clients may refuse; the worker turns them off when it is told so.
@ -133,7 +133,7 @@ pub struct Quirks {
/// Activity for a playing (or paused) media tab, plus the application ID to use. /// Activity for a playing (or paused) media tab, plus the application ID to use.
/// `started` keeps the progress bar steady between polls: (tab id, title, start ms). /// `started` keeps the progress bar steady between polls: (tab id, title, start ms).
pub fn media_activity(settings: &Rpc, tab_url: &Url, tab_title: &str, favicon: &str, state: &MediaState, tab_id: u64, started: &mut Option<(u64, String, i64)>) -> Option<(Value, String)> { pub fn media_activity(settings: &Rpc, tab_url: &Url, tab_title: &str, images: &[&str], state: &MediaState, tab_id: u64, started: &mut Option<(u64, String, i64)>) -> Option<(Value, String)> {
let (key, name, kind, button) = site_for(&util::host_of(tab_url), settings)?; let (key, name, kind, button) = site_for(&util::host_of(tab_url), settings)?;
if state.paused && !settings.show_paused { if state.paused && !settings.show_paused {
return None; return None;
@ -149,8 +149,8 @@ pub fn media_activity(settings: &Rpc, tab_url: &Url, tab_title: &str, favicon: &
art = format!("https://i.ytimg.com/vi/{vid}/hqdefault.jpg"); art = format!("https://i.ytimg.com/vi/{vid}/hqdefault.jpg");
} }
} }
if !https_short(&art) { if !usable_image(&art) {
art = icon_url(&[favicon], tab_url); art = icon_url(images);
} }
let by = if creator != name { format!("by {creator}") } else { name.clone() }; let by = if creator != name { format!("by {creator}") } else { name.clone() };
let mut act = json!({ let mut act = json!({
@ -212,7 +212,7 @@ pub fn browse_activity(settings: &Rpc, url: &Url, title: &str, site_name: &str,
"timestamps": {"start": since_ms}, "timestamps": {"start": since_ms},
"assets": {"large_text": clip(&host, 128)}, "assets": {"large_text": clip(&host, 128)},
}); });
let icon = icon_url(&[image, favicon], url); let icon = icon_url(&[image, favicon]);
if !icon.is_empty() { if !icon.is_empty() {
act["assets"]["large_image"] = json!(icon); act["assets"]["large_image"] = json!(icon);
} }
@ -490,11 +490,12 @@ mod tests {
#[test] #[test]
fn icon_prefers_fetchable_image_then_falls_back() { fn icon_prefers_fetchable_image_then_falls_back() {
let page = Url::parse("https://example.org/a").unwrap(); assert_eq!(icon_url(&["https://x.test/a.png", "https://y.test/f.png"]), "https://x.test/a.png");
assert_eq!(icon_url(&["https://x.test/a.png", "https://y.test/f.png"], &page), "https://x.test/a.png"); assert_eq!(icon_url(&["data:image/png;base64,AAAA", "https://y.test/f.png"]), "https://y.test/f.png");
assert_eq!(icon_url(&["data:image/png;base64,AAAA", "https://y.test/f.png"], &page), "https://y.test/f.png");
let long = format!("https://x.test/{}", "a".repeat(300)); let long = format!("https://x.test/{}", "a".repeat(300));
assert_eq!(icon_url(&["", "http://y.test/f.ico", &long], &page), "https://example.org/favicon.ico"); assert_eq!(icon_url(&["", "http://y.test/f.png", &long]), "");
assert_eq!(icon_url(&[""], &Url::parse("about:blank").unwrap()), ""); // Discord draws ICO and SVG as "?" (discord.com only has /assets/favicon.ico).
assert_eq!(icon_url(&["https://discord.com/assets/favicon.ico", "https://x.test/f.SVG?v=2"]), "");
assert_eq!(icon_url(&["https://x.test/f.ico?v=1", "https://x.test/og.png?w=1"]), "https://x.test/og.png?w=1");
} }
} }

View file

@ -418,7 +418,7 @@ pub struct Update {
impl Default for Update { impl Default for Update {
fn default() -> Self { fn default() -> Self {
Self { repo: "https://archlinux.tail7c4f5e.ts.net/git/astar76/Nacre".to_owned(), last_check: 0, auto_check: true, available: String::new() } Self { repo: "https://astar76.com/git/astar76/Nacre".to_owned(), last_check: 0, auto_check: true, available: String::new() }
} }
} }

View file

@ -247,6 +247,8 @@ pub struct Tab {
pub favicon_colour: Option<egui::Color32>, pub favicon_colour: Option<egui::Color32>,
pub site_name: String, pub site_name: String,
pub page_image: String, pub page_image: String,
/// Largest page icon Discord can show (not ICO/SVG), for Rich Presence.
pub rpc_icon: String,
pub manifest: String, pub manifest: String,
/// When the user arrived on this page (Discord "browsing" timer), ms. /// When the user arrived on this page (Discord "browsing" timer), ms.
pub arrived_ms: u64, pub arrived_ms: u64,
@ -308,6 +310,7 @@ impl Tab {
favicon_colour: None, favicon_colour: None,
site_name: String::new(), site_name: String::new(),
page_image: String::new(), page_image: String::new(),
rpc_icon: String::new(),
manifest: String::new(), manifest: String::new(),
arrived_ms: crate::util::now_ms(), arrived_ms: crate::util::now_ms(),
context: None, context: None,

View file

@ -169,8 +169,36 @@ fn caelestia_primary(text: &str) -> Option<Color32> {
parse_hex(hex) parse_hex(hex)
} }
/// Whether the system prefers dark ("System" mode): GTK's answer, else the GNOME setting. /// The files the desktop's colours come from: Caelestia's scheme.json and KDE's kdeglobals.
pub fn desktop_files() -> Vec<std::path::PathBuf> {
[dirs::state_dir().map(|d| d.join("caelestia/scheme.json")), dirs::config_dir().map(|d| d.join("kdeglobals"))].into_iter().flatten().collect()
}
/// Modification times of `files` (None: missing); a different answer means the desktop's colours may have changed.
pub fn file_stamps(files: &[std::path::PathBuf]) -> Vec<Option<std::time::SystemTime>> {
files.iter().map(|f| std::fs::metadata(f).and_then(|m| m.modified()).ok()).collect()
}
/// The light/dark mode of a Caelestia `scheme.json` (`{"mode": "dark", ...}`).
fn caelestia_dark(text: &str) -> Option<bool> {
let json: serde_json::Value = serde_json::from_str(text).ok()?;
match json.get("mode")?.as_str()? {
"dark" => Some(true),
"light" => Some(false),
_ => None,
}
}
/// Whether the system prefers dark ("System" mode): Caelestia's scheme mode, else GTK's answer, else the GNOME
/// setting.
pub fn system_dark(gtk_dark: Option<bool>) -> bool { pub fn system_dark(gtk_dark: Option<bool>) -> bool {
#[cfg(unix)]
if let Some(path) = dirs::state_dir().map(|d| d.join("caelestia/scheme.json"))
&& let Ok(text) = std::fs::read_to_string(path)
&& let Some(dark) = caelestia_dark(&text)
{
return dark;
}
match gtk_dark { match gtk_dark {
Some(dark) => dark, Some(dark) => dark,
None => { None => {
@ -714,6 +742,30 @@ mod tests {
assert_eq!(caelestia_primary("not json"), None); assert_eq!(caelestia_primary("not json"), None);
} }
#[test]
fn caelestia_scheme_mode() {
assert_eq!(caelestia_dark(r#"{"mode": "light", "colours": {}}"#), Some(false));
assert_eq!(caelestia_dark(r#"{"mode": "dark"}"#), Some(true));
assert_eq!(caelestia_dark(r#"{"colours": {}}"#), None);
}
#[test]
fn desktop_file_changes_are_seen() {
let dir = std::env::temp_dir().join(format!("nacre-theme-test-{}", crate::util::random_hex(6)));
std::fs::create_dir_all(&dir).unwrap();
let files = vec![dir.join("scheme.json"), dir.join("kdeglobals")];
let missing = file_stamps(&files);
assert_eq!(missing, vec![None, None]);
std::fs::write(&files[0], "{}").unwrap();
let written = file_stamps(&files);
assert_ne!(written, missing);
assert_eq!(file_stamps(&files), written);
let later = std::time::SystemTime::now() + std::time::Duration::from_secs(5);
std::fs::File::options().write(true).open(&files[0]).unwrap().set_modified(later).unwrap();
assert_ne!(file_stamps(&files), written);
std::fs::remove_dir_all(&dir).unwrap();
}
#[test] #[test]
fn colours() { fn colours() {
assert_eq!(parse_hex("#6750A4"), Some(Color32::from_rgb(0x67, 0x50, 0xA4))); assert_eq!(parse_hex("#6750A4"), Some(Color32::from_rgb(0x67, 0x50, 0xA4)));

View file

@ -91,7 +91,7 @@ mod tests {
#[test] #[test]
fn api_urls() { fn api_urls() {
assert_eq!(api_url("https://archlinux.tail7c4f5e.ts.net/git/astar76/Nacre").as_deref(), Some("https://archlinux.tail7c4f5e.ts.net/git/api/v1/repos/astar76/Nacre/releases/latest")); assert_eq!(api_url("https://astar76.com/git/astar76/Nacre").as_deref(), Some("https://astar76.com/git/api/v1/repos/astar76/Nacre/releases/latest"));
assert_eq!(api_url("https://github.com/a/b.git").as_deref(), Some("https://api.github.com/repos/a/b/releases/latest")); assert_eq!(api_url("https://github.com/a/b.git").as_deref(), Some("https://api.github.com/repos/a/b/releases/latest"));
assert!(parse_version("v0.10.0") > parse_version("0.9.9")); assert!(parse_version("v0.10.0") > parse_version("0.9.9"));
} }

View file

@ -3,7 +3,7 @@
set -euo pipefail set -euo pipefail
root=$(cd "$(dirname "$0")/.." && pwd) root=$(cd "$(dirname "$0")/.." && pwd)
APP=nacre NAME=Nacre DESKTOP=dev.nacre.Nacre.desktop APP=nacre NAME=Nacre DESKTOP=dev.nacre.Nacre.desktop
URL=https://archlinux.tail7c4f5e.ts.net/git/astar76/Nacre URL=https://astar76.com/git/astar76/Nacre
ver=$(sed -n 's/^version = "\(.*\)"/\1/p' "$root/Cargo.toml" | head -n 1) ver=$(sed -n 's/^version = "\(.*\)"/\1/p' "$root/Cargo.toml" | head -n 1)
BINS=(nacre) EXTRA_ELF=(libnacre_webext.so) BINS=(nacre) EXTRA_ELF=(libnacre_webext.so)
LICENSE=MPL-2.0 NIX_LICENSE=mpl20 SUMMARY='A web browser built on WebKitGTK' LICENSE=MPL-2.0 NIX_LICENSE=mpl20 SUMMARY='A web browser built on WebKitGTK'
@ -130,7 +130,7 @@ cat > "$d/control/control" <<CTL
Package: $APP Package: $APP
Version: $ver Version: $ver
Architecture: amd64 Architecture: amd64
Maintainer: astar76 <[email protected]rchlinux.tail7c4f5e.ts.net> Maintainer: astar76 <[email protected]star76.com>
Installed-Size: $size Installed-Size: $size
Depends: libc6 (>= $glibc)${DEB_DEPENDS:+, $DEB_DEPENDS} Depends: libc6 (>= $glibc)${DEB_DEPENDS:+, $DEB_DEPENDS}
${DEB_RECOMMENDS:+Recommends: $DEB_RECOMMENDS ${DEB_RECOMMENDS:+Recommends: $DEB_RECOMMENDS

View file

@ -1,6 +1,6 @@
[package] [package]
name = "nacre-webext" name = "nacre-webext"
version = "0.4.1" version = "0.4.2"
edition = "2024" edition = "2024"
rust-version = "1.88" rust-version = "1.88"
description = "Nacre's WebKit web process extension: request headers, ad blocker stand-ins, blocked counts (D-036)" description = "Nacre's WebKit web process extension: request headers, ad blocker stand-ins, blocked counts (D-036)"