helium: follow the wallpaper theme via chromium GTK mode, drop its own frame

This commit is contained in:
rope 2026-08-19 17:13:25 +01:00
parent 58a6425898
commit 32bf9680fe
2 changed files with 56 additions and 4 deletions

View file

@ -1,9 +1,61 @@
#./apps/helium.nix #./apps/helium.nix
{ inputs, pkgs, lib, config, ... }: { inputs, pkgs, lib, config, ... }:
let
upstream = inputs.helium-browser.packages.${pkgs.stdenv.hostPlatform.system}.default;
# Helium is ungoogled-chromium, so there is no userChrome.css to render a
# template into the way zen does. Its one themeable surface is chromium's
# GTK mode: with extensions.theme.system_theme = 1 (ui::SystemTheme::kGtk)
# the frame, tabstrip and omnibox come from the GTK3 theme, and chromium
# subscribes to notify::gtk-theme-name — so the gsettings flip at the end of
# theme-apply recolours a RUNNING helium, the same as nemo. Nothing
# per-wallpaper has to be generated for it.
#
# browser.custom_chrome_frame = false is chromium's "Use system title bar and
# borders". Hyprland draws no titlebar, so this only drops chromium's own
# frame, rounded corners and shadow margin — the window fills its tile.
#
# Both are profile prefs and chromium rewrites Preferences from memory on
# exit; no enterprise policy covers either, so there is no declarative way
# in. Patch the file just before launch instead: helium is then either not
# running, and the write sticks, or already running with the prefs applied
# and this process only forwards its arguments to that instance.
seedPrefs = pkgs.writeShellScript "helium-seed-prefs" ''
prefs="$HOME/.config/net.imput.helium/Default/Preferences"
[ -f "$prefs" ] || exit 0
${pkgs.jq}/bin/jq -c '
.extensions.theme.system_theme = 1
| .browser.custom_chrome_frame = false
' "$prefs" > "$prefs.fred" && mv "$prefs.fred" "$prefs" || rm -f "$prefs.fred"
'';
in
{ {
config = lib.mkIf (lib.elem config.networking.hostName [ "FredOS-Gaming" "FredOS-Macbook" ]) { config = lib.mkIf (lib.elem config.networking.hostName [ "FredOS-Gaming" "FredOS-Macbook" ]) {
environment.systemPackages = [ environment.systemPackages = [
inputs.helium-browser.packages.${pkgs.stdenv.hostPlatform.system}.default (pkgs.symlinkJoin {
name = "helium-themed";
paths = [ upstream ];
nativeBuildInputs = [ pkgs.makeWrapper ];
# `|| true` is load-bearing: wrapProgram's wrapper runs under `bash -e`,
# so an unreadable or half-written Preferences would stop the browser
# from starting at all rather than just skipping the theming.
postBuild = ''
wrapProgram $out/bin/helium --run '${seedPrefs} || true'
# A broken filter here is invisible until the browser quietly never
# follows the theme, so patch a stub profile at build time and assert.
(
export HOME=$(mktemp -d)
mkdir -p "$HOME/.config/net.imput.helium/Default"
echo '{"browser":{"custom_chrome_frame":true}}' \
> "$HOME/.config/net.imput.helium/Default/Preferences"
${seedPrefs}
${pkgs.jq}/bin/jq -e '.extensions.theme.system_theme == 1
and .browser.custom_chrome_frame == false' \
"$HOME/.config/net.imput.helium/Default/Preferences" > /dev/null
)
'';
})
]; ];
}; };
} }

View file

@ -7,9 +7,9 @@
# every app that can reload without restarting. # every app that can reload without restarting.
# #
# What follows a switch immediately: quickshell, hyprland, ghostty (D-Bus # What follows a switch immediately: quickshell, hyprland, ghostty (D-Bus
# reload-config), GTK3 apps such as nemo (each wallpaper installs its own # reload-config), GTK3 apps such as nemo and helium (each wallpaper installs
# named GTK theme, switched over gsettings) and the folder icon tint. On next # its own named GTK theme, switched over gsettings) and the folder icon tint.
# launch only: GTK4/libadwaita apps, btop, zen, spotify-player. # On next launch only: GTK4/libadwaita apps, btop, zen, spotify-player.
# #
# stylix stays the source of truth for build-time defaults and for every # stylix stays the source of truth for build-time defaults and for every
# target not listed here — walls/wallpaper.png remains its image. # target not listed here — walls/wallpaper.png remains its image.