Liquid Glass effect for GNU/Emacs

Source: github.com
32 points by lr0 a day ago on lobsters | 4 comments

This repo is a small recipe for building Emacs with a Ghostty-like macOS glass frame. It layers a local Cocoa patch on top of Homebrew emacs-plus@31 and the community frame-transparency patch, then configures Emacs with the same shape as Ghostty:

background-opacity = 0.01
background-blur = macos-glass-regular

This is not a dark overlay or a hard-coded theme. The patch adds native NSGlassEffectView support only.

screenshot.png

For the longer write-up, see the blog post.

What This Builds

The recipe uses the emacs-plus@31 formula, not the emacs-plus-app cask. The cask ships a prebuilt binary and ignores ~/.config/emacs-plus/build.yml, so it cannot apply local patches.

The build applies two patches, in order:

  1. frame-transparency from d12frosted/emacs-plus
  2. patches/ns-glass-effect.patch from this repo

The local patch adds these frame parameters:

ParameterPurpose
ns-glass-materialNative material, currently regular, clear, or nil.
ns-glass-tint-opacityTheme-owned tint opacity over the glass view.
ns-glass-saturationSaturation multiplier for the glass tint.
ns-glass-inactive-opacityOptional opacity when the frame is inactive.
ns-glass-corner-radiusOptional corner radius for the glass view.
ns-alpha-glyphs-alphaSeparate alpha for real glyph backgrounds.

The last parameter is what makes alpha-background values near 0 usable. Without it, hl-line, regions, and completion selections disappear with the frame background.

Quick Start

Install from your tap:

brew tap larrasket/emacs-liquid-glass https://github.com/larrasket/emacs-liquid-glass.git
brew emacs-liquid-glass install

Skip copying the rebuilt app bundle into /Applications:

brew emacs-liquid-glass install --no-copy-app

Direct clone usage also works:

git clone https://github.com/larrasket/emacs-liquid-glass
cd emacs-liquid-glass
./install.sh

Use ./install.sh --no-copy-app if you do not want it to update /Applications/Emacs.app and /Applications/Emacs Client.app.

Manual Build

Copy the patch and build config:

mkdir -p ~/.config/emacs-plus
cp patches/ns-glass-effect.patch ~/.config/emacs-plus/ns-glass-effect.patch
cp config/build.yml ~/.config/emacs-plus/build.yml

Build Emacs from source:

brew tap d12frosted/emacs-plus
HOMEBREW_NO_AUTO_UPDATE=1 brew reinstall emacs-plus@31 --build-from-source
brew postinstall d12frosted/emacs-plus/emacs-plus@31

Copy the app bundles used by Spotlight and /opt/homebrew/bin/emacs:

rsync -a --delete /opt/homebrew/opt/emacs-plus@31/Emacs.app/ /Applications/Emacs.app/
rsync -a --delete "/opt/homebrew/opt/emacs-plus@31/Emacs Client.app/" "/Applications/Emacs Client.app/"

Emacs Config

Load lisp/lr-macos-glass.el from your Emacs config. If this repo is installed as a Homebrew tap, you can find its path with:

brew emacs-liquid-glass path

Example:

(add-to-list 'load-path "/path/to/emacs-liquid-glass/lisp")
(require 'lr-macos-glass)

The regular preset currently uses:

(setq salih/glass-style 'macos-glass-regular
      salih/alpha-background 0.01
      salih/ns-background-blur 0
      salih/ns-alpha-glyphs-min-alpha 0.24
      salih/ns-glass-material 'regular
      salih/ns-glass-tint-opacity 0.05
      salih/ns-glass-saturation 1.9
      salih/ns-glass-inactive-opacity 0.05
      salih/ns-glass-corner-radius 2
      salih/ns-transparent-titlebar t)

Interactive commands:

CommandEffect
M-x salih/set-glass-styleSwitch between macos-glass-regular and macos-glass-clear.
M-x salih/set-glassSet frame alpha and CGS blur.
M-x salih/set-glass-glyph-alphaSet highlight/selection glyph background alpha.
M-x salih/toggle-glassToggle between the glass frame and an opaque frame.

If you set salih/alpha-background to 0, keep salih/ns-alpha-glyphs-min-alpha above 0 if you still want hl-line, regions, and completion selections to be visible.

Verification

If you find issue, please first check that the installed binary contains the new frame parameters:

strings /Applications/Emacs.app/Contents/MacOS/Emacs \
  | rg 'ns-alpha-glyphs-alpha|ns-glass-material|ns-glass-saturation'

If emacs reports an invalid ns-glass-* value, you are probably running an older build than the app bundle you just compiled. Fully quit GUI Emacs, restart the daemon if you use one, and make sure /Applications/Emacs.app was copied from /opt/homebrew/opt/emacs-plus@31/Emacs.app.

Notes

This has been tested on macOS with Homebrew emacs-plus@31. It should not be expected to work on GNU/Linux, Windows, terminal Emacs, or the prebuilt emacs-plus-app cask.