← 返回日报
精读 预计 2 分钟

Liquid Glass effect for GNU/Emacs

摘要

这是一个 GitHub 仓库,提供在 macOS 上为 GNU Emacs 构建类似 Ghostty 的 Liquid Glass 玻璃效果的完整配方。它基于 Homebrew 的 emacs-plus@31 公式,叠加本地 Cocoa 补丁和社区透明度补丁,新增多个 ns-glass-* 帧参数,并给出安装、手动构建、配置和验证步骤。内容明确说明不适用于 Linux、Windows 或终端 Emacs,且必须使用 emacs-plus@31 公式而非预编译 cask。

荐读理由

该仓库提供了从 Homebrew 公式到本地补丁、配置参数和验证命令的完整可操作步骤,你可以在自己的 macOS Emacs 环境中复现,并利用 ns-glass-* 参数精细控制玻璃材质、透明度、圆角等,避免 alpha 背景导致选区不可见的坑。

原文

Emacs Liquid Glass

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:

Parameter Purpose
ns-glass-material Native material, currently regular, clear, or nil.
ns-glass-tint-opacity Theme-owned tint opacity over the glass view.
ns-glass-saturation Saturation multiplier for the glass tint.
ns-glass-inactive-opacity Optional opacity when the frame is inactive.
ns-glass-corner-radius Optional corner radius for the glass view.
ns-alpha-glyphs-alpha Separate 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:

Command Effect
M-x salih/set-glass-style Switch between macos-glass-regular and macos-glass-clear.
M-x salih/set-glass Set frame alpha and CGS blur.
M-x salih/set-glass-glyph-alpha Set highlight/selection glyph background alpha.
M-x salih/toggle-glass Toggle 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.

Lobsters · 2 赞 · 0 评 讨论 → 阅读原文 →

这条对你有帮助吗?