diff --git a/CLAUDE.md b/CLAUDE.md index 81517d1..d524846 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -37,7 +37,7 @@ Never modify: `~/Documents/Apps/Nacre` (the original Python Nacre, reference onl ## 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/`. -- 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. +- 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. - 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. - Known gaps and things to check at the first build: `docs/REVIEW.md`. Feature list with file and review state: `docs/FEATURES.md`. diff --git a/Cargo.lock b/Cargo.lock index 95e447e..2036dab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1899,7 +1899,7 @@ dependencies = [ [[package]] name = "nacre" -version = "0.4.2" +version = "0.4.1" dependencies = [ "adblock", "arboard", @@ -1935,7 +1935,7 @@ dependencies = [ [[package]] name = "nacre-webext" -version = "0.4.2" +version = "0.4.1" dependencies = [ "glib-sys", "gobject-sys", diff --git a/Cargo.toml b/Cargo.toml index 70655a3..4894b33 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nacre" -version = "0.4.2" +version = "0.4.1" edition = "2024" rust-version = "1.88" description = "Nacre, a web browser built on WebKitGTK" diff --git a/README.md b/README.md index ff8d77f..c774fb9 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Linux only: WebKitGTK has no Windows or macOS build. ## Install -Downloads are on the [Releases page](https://astar76.com/git/astar76/Nacre/releases). Check them +Downloads are on the [Releases page](https://archlinux.tail7c4f5e.ts.net/git/astar76/Nacre/releases). Check them against `SHA256SUMS-`. - **Arch Linux:** `sudo pacman -U Nacre--arch-x86_64.pkg.tar.zst` (package `nacre-bin`; remove it with @@ -23,7 +23,7 @@ against `SHA256SUMS-`. To build from this checkout instead: `./install.sh` (package `nacre`). - **Debian, Ubuntu and other apt systems:** `sudo apt install ./Nacre--amd64.deb`. Needs WebKitGTK 6.0 and a glibc as new as the one named in the package (recent releases only). -- **Nix:** `nix profile install git+https://astar76.com/git/astar76/Nacre` (flake), or +- **Nix:** `nix profile install git+https://archlinux.tail7c4f5e.ts.net/git/astar76/Nacre` (flake), or `callPackage ./packaging/nix { }`. - **Any distribution:** unpack `Nacre--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 diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md index 7d2cbaf..69dfa4a 100644 --- a/docs/PROGRESS.md +++ b/docs/PROGRESS.md @@ -575,12 +575,6 @@ 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). - 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 - 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). @@ -589,12 +583,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). - 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). -- System accent: the GNOME portal `accent-color` isn't watched live (only Caelestia's scheme.json and kdeglobals). +- System accent: watch caelestia scheme.json / the portal `accent-color` and restyle live (R1-11). - Reader mode, split view, translate, real gamepad rumble (D-002: not planned for now). - AppImage / tar.gz release (D-001, D-054). - 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). - A test run (fresh profile, internet) moves ~200 KB before the first page and looks up the update host - (astar76.com); find out which background fetch it is, maybe skip it in smoke runs (S007). + (archlinux.tail7c4f5e.ts.net); 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 treated as downloads (what Servo then shows wasn't checked) (S007). diff --git a/docs/releases/0.4.2.md b/docs/releases/0.4.2.md deleted file mode 100644 index a1f50c8..0000000 --- a/docs/releases/0.4.2.md +++ /dev/null @@ -1,9 +0,0 @@ -# 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). diff --git a/packaging/arch-bin/.SRCINFO b/packaging/arch-bin/.SRCINFO index 8d53b6f..90059f1 100644 --- a/packaging/arch-bin/.SRCINFO +++ b/packaging/arch-bin/.SRCINFO @@ -1,8 +1,8 @@ pkgbase = nacre-bin pkgdesc = A web browser built on WebKitGTK - pkgver = 0.4.2 + pkgver = 0.4.1 pkgrel = 1 - url = https://astar76.com/git/astar76/Nacre + url = https://archlinux.tail7c4f5e.ts.net/git/astar76/Nacre arch = x86_64 license = MPL-2.0 depends = glibc>=2.43 @@ -29,7 +29,7 @@ pkgbase = nacre-bin conflicts = nacre options = !strip options = !debug - 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 = c4865f30221bddd62fbb812781cdfe5974c615bebaf73b215e64e3a6867ab97a + 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 + sha256sums = 35902a2a539a53320814e9fd4ff670c118153fd8eaa6c788ef2dcf37bdcb2cff pkgname = nacre-bin diff --git a/packaging/arch-bin/PKGBUILD b/packaging/arch-bin/PKGBUILD index b8dd6aa..744cbd1 100644 --- a/packaging/arch-bin/PKGBUILD +++ b/packaging/arch-bin/PKGBUILD @@ -2,11 +2,11 @@ # 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. pkgname=nacre-bin -pkgver=0.4.2 +pkgver=0.4.1 pkgrel=1 pkgdesc='A web browser built on WebKitGTK' arch=('x86_64') -url='https://astar76.com/git/astar76/Nacre' +url='https://archlinux.tail7c4f5e.ts.net/git/astar76/Nacre' 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') optdepends=( @@ -20,7 +20,7 @@ provides=('nacre') conflicts=('nacre') options=('!strip' '!debug') source=("Nacre-$pkgver-Linux-x86_64.tar.gz::${TARBALL:-$url/releases/download/v$pkgver/Nacre-$pkgver-Linux-x86_64.tar.gz}") -sha256sums=('c4865f30221bddd62fbb812781cdfe5974c615bebaf73b215e64e3a6867ab97a') +sha256sums=('35902a2a539a53320814e9fd4ff670c118153fd8eaa6c788ef2dcf37bdcb2cff') package() { cd "$srcdir/nacre-$pkgver" diff --git a/packaging/arch/PKGBUILD b/packaging/arch/PKGBUILD index b01b283..dd0fc14 100644 --- a/packaging/arch/PKGBUILD +++ b/packaging/arch/PKGBUILD @@ -4,7 +4,7 @@ pkgver=0.4.0 pkgrel=1 pkgdesc="A web browser built on WebKitGTK" arch=(x86_64) -url="https://astar76.com/git/astar76/Nacre" +url="https://archlinux.tail7c4f5e.ts.net/git/astar76/Nacre" 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) makedepends=(cargo git pkgconf) diff --git a/packaging/nix/default.nix b/packaging/nix/default.nix index 15d3fec..6fb4f28 100644 --- a/packaging/nix/default.nix +++ b/packaging/nix/default.nix @@ -4,10 +4,10 @@ stdenv.mkDerivation rec { pname = "nacre"; - version = "0.4.2"; + version = "0.4.1"; src = fetchurl { - url = "https://astar76.com/git/astar76/Nacre/releases/download/v${version}/Nacre-${version}-Linux-x86_64.tar.gz"; - hash = "sha256-xIZfMCIb3dYvu4Engc3+WXTGFb669zshXmTjpoZ6uXo="; + url = "https://archlinux.tail7c4f5e.ts.net/git/astar76/Nacre/releases/download/v${version}/Nacre-${version}-Linux-x86_64.tar.gz"; + hash = "sha256-NZAqKlOaUzIIFOn9T/ZwwRgVP9jqpseI7y3PN73LLP8="; }; 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 ]; @@ -24,7 +24,7 @@ stdenv.mkDerivation rec { meta = { description = "A web browser built on WebKitGTK"; - homepage = "https://astar76.com/git/astar76/Nacre"; + homepage = "https://archlinux.tail7c4f5e.ts.net/git/astar76/Nacre"; license = lib.licenses.mpl20; platforms = [ "x86_64-linux" ]; mainProgram = "nacre"; diff --git a/src/actions.rs b/src/actions.rs index 833583c..7e84342 100644 --- a/src/actions.rs +++ b/src/actions.rs @@ -1672,8 +1672,7 @@ impl App { "ready" => {}, "meta" => { let color = crate::theme::parse_css_color(&s(&data, "theme_color")); - let icons: Vec = 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 icon = data.get("icons").and_then(|v| v.as_array()).and_then(|a| a.first()).map(|i| s(i, "href")).unwrap_or_default(); let changed; { let tab = &mut self.windows.get_mut(&w).expect("found").tabs[i]; @@ -1681,7 +1680,6 @@ impl App { tab.theme_color = color; tab.site_name = s(&data, "site_name"); 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"); if !icon.is_empty() { tab.favicon_url = icon; @@ -2244,14 +2242,14 @@ impl App { } let mut state = state.clone(); state.position = state.position_at(*received); - activity = crate::discord::media_activity(&settings, &url, &tab.title, &[&tab.rpc_icon, &tab.page_image], &state, tab.id, &mut self.presence_started); + activity = crate::discord::media_activity(&settings, &url, &tab.title, &tab.favicon_url, &state, tab.id, &mut self.presence_started); } if activity.is_none() && let Some(win) = self.current_window().and_then(|w| self.windows.get(&w)) && let Some(tab) = win.tab() && tab.page.is_none() && 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.rpc_icon, tab.arrived_ms as i64) + && 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) { activity = Some((act, settings.client_id.clone())); } diff --git a/src/app.rs b/src/app.rs index 679d179..d5b4bbd 100644 --- a/src/app.rs +++ b/src/app.rs @@ -143,7 +143,7 @@ pub struct Shared { pub vpn_status: RefCell, pub speller: RefCell>, pub spell_status: RefCell, - pub system_accent: Cell>, + pub system_accent: Option, pub user_agent: RefCell, pub devtools: RefCell>, pub update: RefCell>, @@ -241,8 +241,6 @@ pub struct App { /// A quit or window close waiting for the pages' `beforeunload`. pub shutdown: Option, last_tick: Instant, - /// Modification times of the desktop's colour files (`theme::desktop_files`), to follow them live. - desktop_stamps: Vec>, last_save: Instant, last_slow: Instant, /// Sealed cookies (D-037), `None` when they are kept for the run only. @@ -315,7 +313,7 @@ impl App { vpn_status: RefCell::new(VpnStatus::Off), speller: RefCell::new(None), spell_status: RefCell::new(String::new()), - system_accent: Cell::new(theme::system_accent()), + system_accent: theme::system_accent(), user_agent: RefCell::new(String::new()), devtools: RefCell::new(None), update: RefCell::new(None), @@ -370,7 +368,6 @@ impl App { exiting: false, shutdown: None, last_tick: Instant::now(), - desktop_stamps: theme::file_stamps(&theme::desktop_files()), last_save: Instant::now(), last_slow: Instant::now() - Duration::from_secs(3600), cookies: None, @@ -1280,14 +1277,6 @@ impl App { if self.shared.toasts.borrow().len() != before { 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. let busy: Vec = self.windows.iter().filter(|(_, w)| w.tabs.iter().any(|t| t.loading() || t.audible())).map(|(id, _)| *id).collect(); for w in busy { @@ -1629,7 +1618,7 @@ impl App { let settings = self.shared.settings.borrow(); let dark = theme::is_dark(&settings, *self.shared.system_dark.borrow()); let site = win.tab().and_then(Tab::site_colour); - let palette = theme::Palette::new(theme::seed(&settings, site, self.shared.system_accent.get()), dark, &settings.theme.variant, settings.theme.contrast); + let palette = theme::Palette::new(theme::seed(&settings, site, self.shared.system_accent), dark, &settings.theme.variant, settings.theme.contrast); let ctx = win.ctx(); theme::apply(&ctx, &palette, &settings); // Always, so going back to 100 % takes effect too. diff --git a/src/discord.rs b/src/discord.rs index 3872f79..1691799 100644 --- a/src/discord.rs +++ b/src/discord.rs @@ -111,17 +111,17 @@ fn https_short(url: &str) -> bool { url.starts_with("https://") && url.len() <= 256 } -/// An image Discord can show: a short https URL that isn't ICO or SVG (Discord draws those as "?"). -pub fn usable_image(url: &str) -> bool { - let path = url.split(['?', '#']).next().unwrap_or("").to_ascii_lowercase(); - https_short(url) && !path.ends_with(".ico") && !path.ends_with(".svg") -} - -/// Image for the activity's large icon: the first of `images` Discord can show, else none, so -/// Discord shows the application's own icon (no third-party favicon service, so no visited host -/// leaks beyond Discord). -fn icon_url(images: &[&str]) -> String { - images.iter().find(|i| usable_image(i)).map(|i| (*i).to_owned()).unwrap_or_default() +/// Image for the activity's large icon: the first of `images` Discord can fetch (short https URL), +/// else the page origin's /favicon.ico (data:/http:/long favicon URLs are unusable; no third-party +/// service, so no visited host leaks beyond Discord). Empty for pages without a host. +fn icon_url(images: &[&str], page: &Url) -> String { + if let Some(img) = images.iter().find(|i| https_short(i)) { + return (*img).to_owned(); + } + match page.host_str() { + Some(host) if matches!(page.scheme(), "http" | "https") => format!("https://{host}/favicon.ico"), + _ => String::new(), + } } /// 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. /// `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, images: &[&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, favicon: &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)?; if state.paused && !settings.show_paused { return None; @@ -149,8 +149,8 @@ pub fn media_activity(settings: &Rpc, tab_url: &Url, tab_title: &str, images: &[ art = format!("https://i.ytimg.com/vi/{vid}/hqdefault.jpg"); } } - if !usable_image(&art) { - art = icon_url(images); + if !https_short(&art) { + art = icon_url(&[favicon], tab_url); } let by = if creator != name { format!("by {creator}") } else { name.clone() }; 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}, "assets": {"large_text": clip(&host, 128)}, }); - let icon = icon_url(&[image, favicon]); + let icon = icon_url(&[image, favicon], url); if !icon.is_empty() { act["assets"]["large_image"] = json!(icon); } @@ -490,12 +490,11 @@ mod tests { #[test] fn icon_prefers_fetchable_image_then_falls_back() { - assert_eq!(icon_url(&["https://x.test/a.png", "https://y.test/f.png"]), "https://x.test/a.png"); - assert_eq!(icon_url(&["data:image/png;base64,AAAA", "https://y.test/f.png"]), "https://y.test/f.png"); + let page = Url::parse("https://example.org/a").unwrap(); + 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"], &page), "https://y.test/f.png"); let long = format!("https://x.test/{}", "a".repeat(300)); - assert_eq!(icon_url(&["", "http://y.test/f.png", &long]), ""); - // 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"); + assert_eq!(icon_url(&["", "http://y.test/f.ico", &long], &page), "https://example.org/favicon.ico"); + assert_eq!(icon_url(&[""], &Url::parse("about:blank").unwrap()), ""); } } diff --git a/src/store/settings.rs b/src/store/settings.rs index 97934ef..2db7f01 100644 --- a/src/store/settings.rs +++ b/src/store/settings.rs @@ -418,7 +418,7 @@ pub struct Update { impl Default for Update { fn default() -> Self { - Self { repo: "https://astar76.com/git/astar76/Nacre".to_owned(), last_check: 0, auto_check: true, available: String::new() } + Self { repo: "https://archlinux.tail7c4f5e.ts.net/git/astar76/Nacre".to_owned(), last_check: 0, auto_check: true, available: String::new() } } } diff --git a/src/tabs.rs b/src/tabs.rs index 745255b..34133b9 100644 --- a/src/tabs.rs +++ b/src/tabs.rs @@ -247,8 +247,6 @@ pub struct Tab { pub favicon_colour: Option, pub site_name: String, pub page_image: String, - /// Largest page icon Discord can show (not ICO/SVG), for Rich Presence. - pub rpc_icon: String, pub manifest: String, /// When the user arrived on this page (Discord "browsing" timer), ms. pub arrived_ms: u64, @@ -310,7 +308,6 @@ impl Tab { favicon_colour: None, site_name: String::new(), page_image: String::new(), - rpc_icon: String::new(), manifest: String::new(), arrived_ms: crate::util::now_ms(), context: None, diff --git a/src/theme.rs b/src/theme.rs index 8f388a0..7625de4 100644 --- a/src/theme.rs +++ b/src/theme.rs @@ -169,36 +169,8 @@ fn caelestia_primary(text: &str) -> Option { parse_hex(hex) } -/// The files the desktop's colours come from: Caelestia's scheme.json and KDE's kdeglobals. -pub fn desktop_files() -> Vec { - [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> { - 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 { - 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. +/// Whether the system prefers dark ("System" mode): GTK's answer, else the GNOME setting. pub fn system_dark(gtk_dark: Option) -> 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 { Some(dark) => dark, None => { @@ -742,30 +714,6 @@ mod tests { 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] fn colours() { assert_eq!(parse_hex("#6750A4"), Some(Color32::from_rgb(0x67, 0x50, 0xA4))); diff --git a/src/updates.rs b/src/updates.rs index 86931f7..f3f8dee 100644 --- a/src/updates.rs +++ b/src/updates.rs @@ -91,7 +91,7 @@ mod tests { #[test] fn api_urls() { - 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://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://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")); } diff --git a/tools/package.sh b/tools/package.sh index a884096..43e5129 100755 --- a/tools/package.sh +++ b/tools/package.sh @@ -3,7 +3,7 @@ set -euo pipefail root=$(cd "$(dirname "$0")/.." && pwd) APP=nacre NAME=Nacre DESKTOP=dev.nacre.Nacre.desktop -URL=https://astar76.com/git/astar76/Nacre +URL=https://archlinux.tail7c4f5e.ts.net/git/astar76/Nacre ver=$(sed -n 's/^version = "\(.*\)"/\1/p' "$root/Cargo.toml" | head -n 1) BINS=(nacre) EXTRA_ELF=(libnacre_webext.so) LICENSE=MPL-2.0 NIX_LICENSE=mpl20 SUMMARY='A web browser built on WebKitGTK' @@ -130,7 +130,7 @@ cat > "$d/control/control" < +Maintainer: astar76 Installed-Size: $size Depends: libc6 (>= $glibc)${DEB_DEPENDS:+, $DEB_DEPENDS} ${DEB_RECOMMENDS:+Recommends: $DEB_RECOMMENDS diff --git a/webext/Cargo.toml b/webext/Cargo.toml index b393c93..73573a3 100644 --- a/webext/Cargo.toml +++ b/webext/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nacre-webext" -version = "0.4.2" +version = "0.4.1" edition = "2024" rust-version = "1.88" description = "Nacre's WebKit web process extension: request headers, ad blocker stand-ins, blocked counts (D-036)"