Remove the forge "unfocused-border" patch

The patch rewrote forge's window.js with `sed`/`awk` anchored on
exact upstream lines, making it the most fragile piece of the
repository, for a purely cosmetic hairline on unfocused windows.

This also simplifies a future migration away from forge.
This commit is contained in:
Alexander Hess 2026-08-28 20:33:46 +02:00
commit 86cce2d9cf
Signed by: alexander
GPG key ID: B46EDB4DFC26805D
5 changed files with 9 additions and 111 deletions

View file

@ -32,8 +32,6 @@ Process:
4. Patch a broken backup path in the installed `forge` extension (`theme.js`)
5. Ensure the enabled GNOME extensions' schemas are imported
6. Load every `*.ini` here, then every `local/*.ini`
7. Apply a small [patch](../../.local/bin/gnome-shell-extension-forge-patch)
to the `forge` extension to draw borders on unfocused windows
[`dconf-load`](../../.local/bin/dconf-load) captures step 6 as an independent utility,
or for just one file given as an argument,

View file

@ -255,14 +255,13 @@ format='%A %B %-d, %Y %H:%M:%S %Z%z'
# Rounds all window corners uniformly (e.g., needed for `alacritty`)
#
# The rings drawn by forge sit 1px outside the frame and therefore use
# a "border-radius" of 13px (12px + 1px inset) in
# The rings drawn by forge sit outside the window frame
# and use a "border-radius" of 13px in
# ~/.config/forge/stylesheet/forge/stylesheet.css so their curves
# stay concentric with the 12px window corners
# stay roughly concentric with the 12px window corners
#
# "padding" stays 0 because the unfocused borders drawn by
# ~/.local/bin/gnome-shell-extension-forge-patch sit 1px outside
# the window frame (its "inset" of 1) and never cover the contents
# "padding" stays 0 because forge draws its focus rings outside
# the window frame and they never cover the contents
#
custom-rounded-corner-settings=@a{sv} {}
global-rounded-corner-settings={'padding': <{'left': uint32 0, 'right': 0, 'top': 0, 'bottom': 0}>, 'keepRoundedCorners': <{'maximized': true, 'fullscreen': true}>, 'borderRadius': <uint32 12>, 'smoothing': <0.0>, 'borderColor': <(0.6, 0.149, 0.0, 1.0)>, 'enabled': <true>}

View file

@ -157,14 +157,10 @@ _LIGHTNESS_RESOLUTION = 0.001
# Corner geometry:
# - Windows are clipped to `WINDOW_RADIUS`
# by the rounded-window-corners-reborn extension
# - forge's stock focused rings sit `FOCUSED_INSET` outside the frame,
# while the patched unfocused hairline sits `BORDER_INSET` outside
# => Flush rings need radius + their own inset
# - `BORDER_INSET` must match ~/.local/bin/gnome-shell-extension-forge-patch
# - `FOCUSED_INSET` must match `inset` in forge's window.js (currently 3)
# - forge's rings sit slightly outside the window frame
# => The ring radius adds 1px so the curves stay concentric
# (forge's stock inset is actually 3; see window.js)
WINDOW_RADIUS = 12
BORDER_INSET = 1
FOCUSED_INSET = 3
# Template for the stylesheet used by the GNOME shell extension `forge`
@ -174,16 +170,6 @@ FORGE_CSS = textwrap.dedent("""\
/* accent={accent_name} scheme={scheme_name} */
}}
.window-unfocused-border {{
/* Unfocused windows are marked by a hairline only: */
/* - Shadows from rounded-window-corners-reborn carry the focus distinction */
/* - Width is kept > 0 so the patched border code in forge stays exercised */
border-width: 1px;
border-color: {chrome_quiet};
border-style: solid;
border-radius: {unfocused_ring_radius};
}}
.tiled {{
color: {text};
opacity: 1;
@ -836,8 +822,7 @@ def render_forge_css(colors: dict[str, str]) -> str:
emphasis_dim=as_rgb(colors["emphasis-dim"]),
emphasis_dim_a30=as_rgba(colors["emphasis-dim"], alpha=0.3),
emphasis_dim_a40=as_rgba(colors["emphasis-dim"], alpha=0.4),
ring_radius=f"{WINDOW_RADIUS + FOCUSED_INSET}px",
unfocused_ring_radius=f"{WINDOW_RADIUS + BORDER_INSET}px",
ring_radius=f"{WINDOW_RADIUS + 1}px",
scheme_name=colors["_scheme"],
surface_dim=as_rgb(colors["surface-dim"]),
surface_dim_a60=as_rgba(colors["surface-dim"], alpha=0.6),

View file

@ -138,15 +138,4 @@ fi
echo "Patching forge"
# Draw a whitish border on unfocused windows as well
PATCH="$HOME/.local/bin/gnome-shell-extension-forge-patch"
if [ -x "$PATCH" ]; then
"$PATCH" || echo "WARN: forge border patch failed" >&2
fi
echo "Restored GNOME to the defaults defined in ~/.config/gnome-settings"

View file

@ -1,73 +0,0 @@
#!/bin/sh
# Patch `forge` to draw a border on all tiled and unfocused windows
#
# Idempotent: Re-running on a patched file changes nothing
set -eu
XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
WINDOW_JS="$XDG_DATA_HOME/gnome-shell/extensions/forge@jmmaranan.com/lib/extension/window.js"
[ -w "$WINDOW_JS" ] || { echo "Not writable or missing: $WINDOW_JS" >&2; exit 1; }
grep -q "showUnfocusedBorders" "$WINDOW_JS" && { echo "Already patched"; exit 0; }
# Call our method after the focused border is drawn
sed -i '/^ updateBorderLayout() {$/,/^ }$/ s|this\.showWindowBorders();|this.showWindowBorders();\n this.showUnfocusedBorders();|' "$WINDOW_JS"
# Append the method right after `updateBorderLayout()`
awk '
/^ updateBorderLayout\(\) \{$/ { inFn=1 }
inFn && /^ \}$/ {
print
print ""
print " showUnfocusedBorders() {"
print " if (!this.ext.settings.get_boolean(\"focus-border-toggle\")) return;"
print " this.tree.nodeWindows.forEach((nodeWindow) => {"
print " let metaWindow = nodeWindow.nodeValue;"
print " if (!metaWindow || metaWindow === this.focusMetaWindow) return;"
print " if (metaWindow.minimized || metaWindow.is_fullscreen()) return;"
print " if (metaWindow.get_workspace() !== global.workspace_manager.get_active_workspace()) return;"
print " let maximized = false;"
print " try { maximized = metaWindow.is_maximized(); }"
print " catch (e) { maximized = metaWindow.get_maximized() === 3; }"
print " if (maximized) return;"
print " if (nodeWindow.parentNode.isTabbed() || nodeWindow.parentNode.isStacked()) return;"
print " let windowActor = metaWindow.get_compositor_private();"
print " if (!windowActor || !windowActor.border) return;"
print " let border = windowActor.border;"
print " border.set_style_class_name(\"window-unfocused-border\");"
print " let rect = metaWindow.get_frame_rect();"
print " let inset = 1;"
print " border.set_size(rect.width + inset * 2, rect.height + inset * 2);"
print " border.set_position(rect.x - inset, rect.y - inset);"
print " border.show();"
print " if (global.window_group && global.window_group.contains(border)) {"
print " global.window_group.remove_child(border);"
print " global.window_group.insert_child_above(border, windowActor);"
print " }"
print " });"
print " }"
inFn=0
next
}
{ print }
' "$WINDOW_JS" > "$WINDOW_JS.tmp" && mv "$WINDOW_JS.tmp" "$WINDOW_JS"
grep -q 'this\.showUnfocusedBorders();' "$WINDOW_JS" \
&& grep -q 'showUnfocusedBorders() {' "$WINDOW_JS" \
|| {
echo "ERROR: patch anchors did not match (upstream changed?): $WINDOW_JS" >&2
exit 1
}
echo "Patched: $WINDOW_JS"