From 060c57b4aa416022343893c1a2e4eadae255257e Mon Sep 17 00:00:00 2001 From: Rob Zolkos Date: Wed, 7 Oct 2026 14:03:36 -0400 Subject: [PATCH] Enable overlay scrollbars in Chromium (#14456) * Enable overlay scrollbars in Chromium * Test overlay scrollbar migration * Simplify Chromium overlay scrollbar migration --------- Co-authored-by: David Heinemeier Hansson --- config/chromium-flags.conf | 2 +- migrations/1791376887.sh | 15 ++++++ ...omium-overlay-scrollbars-migration-test.sh | 46 +++++++++++++++++++ 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 migrations/1791376887.sh create mode 100644 test/shell.d/chromium-overlay-scrollbars-migration-test.sh diff --git a/config/chromium-flags.conf b/config/chromium-flags.conf index 1fe08716..8c6065c7 100644 --- a/config/chromium-flags.conf +++ b/config/chromium-flags.conf @@ -1,5 +1,5 @@ --ozone-platform=wayland --ozone-platform-hint=wayland --password-store=gnome-libsecret ---enable-features=TouchpadOverscrollHistoryNavigation +--enable-features=TouchpadOverscrollHistoryNavigation,OverlayScrollbar --load-extension=/usr/share/omarchy/default/chromium/extensions/copy-url,/usr/share/omarchy/default/chromium/extensions/yt-dlp,/usr/share/omarchy/default/chromium/extensions/whatsapp-slim diff --git a/migrations/1791376887.sh b/migrations/1791376887.sh new file mode 100644 index 00000000..6f666a7d --- /dev/null +++ b/migrations/1791376887.sh @@ -0,0 +1,15 @@ +echo "Enable overlay scrollbars in Chromium-based browsers" + +for flags_file in "$HOME"/.config/{chromium,chrome,microsoft-edge-stable,brave,brave-origin}-flags.conf; do + [[ -f $flags_file ]] || continue + grep -Eq -- '^--enable-features=([^,]+,)*OverlayScrollbar([,:]|$)' "$flags_file" && continue + + if grep -q -- '^--enable-features=' "$flags_file"; then + sed -i --follow-symlinks \ + -e '/^--enable-features=/ s/$/,OverlayScrollbar/' \ + -e '/^--enable-features=/ s/=,/=/' "$flags_file" + else + [[ -n $(tail -c1 "$flags_file") ]] && echo >>"$flags_file" + echo '--enable-features=OverlayScrollbar' >>"$flags_file" + fi +done diff --git a/test/shell.d/chromium-overlay-scrollbars-migration-test.sh b/test/shell.d/chromium-overlay-scrollbars-migration-test.sh new file mode 100644 index 00000000..50a4d7e5 --- /dev/null +++ b/test/shell.d/chromium-overlay-scrollbars-migration-test.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +set -euo pipefail + +source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" + +migration="$ROOT/migrations/1791376887.sh" +test_tmp=$(mktemp -d) +trap 'rm -rf "$test_tmp"' EXIT + +home="$test_tmp/home" +config_dir="$home/.config" +mkdir -p "$config_dir" "$test_tmp/targets" + +printf '%s\n' '--enable-features=TouchpadOverscrollHistoryNavigation' >"$config_dir/chromium-flags.conf" +printf '%s\n' '--enable-features=' >"$config_dir/chrome-flags.conf" +printf '%s' '--ozone-platform=wayland' >"$config_dir/microsoft-edge-stable-flags.conf" +printf '%s\n' '--enable-features=BraveFeature' >"$test_tmp/targets/brave-flags.conf" +ln -s "$test_tmp/targets/brave-flags.conf" "$config_dir/brave-flags.conf" + +run_migration() { + HOME="$home" bash -euo pipefail "$migration" >/dev/null +} + +run_migration +run_migration + +grep -Fxq -- '--enable-features=TouchpadOverscrollHistoryNavigation,OverlayScrollbar' "$config_dir/chromium-flags.conf" || + fail "the migration preserves existing Chromium features" +overlay_count=$(grep -o 'OverlayScrollbar' "$config_dir/chromium-flags.conf" | wc -l) +(( overlay_count == 1 )) || fail "the migration does not duplicate the Chromium feature" +pass "the migration preserves existing features and can run twice" + +[[ $(cat "$config_dir/chrome-flags.conf") == '--enable-features=OverlayScrollbar' ]] || + fail "the migration fills an empty feature list" +[[ $(cat "$config_dir/microsoft-edge-stable-flags.conf") == $'--ozone-platform=wayland\n--enable-features=OverlayScrollbar' ]] || + fail "the migration adds a feature list with a missing trailing newline" +pass "the migration handles empty and missing feature lists" + +[[ -L $config_dir/brave-flags.conf ]] || fail "the migration preserves symlinked browser flags" +grep -Fxq -- '--enable-features=BraveFeature,OverlayScrollbar' "$config_dir/brave-flags.conf" || + fail "the migration updates the target of symlinked browser flags" +pass "the migration follows symlinked browser flags" + +[[ ! -e $config_dir/brave-origin-flags.conf ]] || fail "the migration leaves missing browser flags absent" +pass "the migration skips missing browser flags"