Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ A series of `*.icns` files are provided for macOS 15 and earlier, and a

## Usage

### TLDR

Open Terminal.app (or any other terminal application you have), copy the command below, and press Enter.

``` shell
curl -fsSL https://github.com/jimeh/emacs-liquid-glass-icons/raw/refs/heads/main/patch-emacs-icon.sh | bash -s -- LG1 /Applications/Emacs.app
```

(Change the `LG1` argument to your preferred icon [available options: `LG1`, `LG2`, or `LG3`], and update `/Applications/Emacs.app` to your Emacs installation path if it is not in the standard location.)

### macOS 15 and earlier

Grab the `.icns` file you prefer from the `Resources` directory, and replace
Expand Down
45 changes: 45 additions & 0 deletions patch-emacs-icon.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash

if [[ ! "$1" =~ ^LG[123]$ ]]; then
echo "Usage: $0 [LG1|LG2|LG3]"
exit 1
fi

# Download file to a tmp dir
TMPDIR=$(mktemp -d) && cd "$TMPDIR" || exit
curl -LO https://github.com/jimeh/emacs-liquid-glass-icons/raw/refs/heads/main/Resources/Assets.car
curl -Lo Emacs.icns "https://github.com/jimeh/emacs-liquid-glass-icons/raw/refs/heads/main/Resources/Emacs$1-Default.icns"

APPDIR="${2:-/Applications/Emacs.app}"

# Get realpath if it's a macOS alias,
# taken from https://stackoverflow.com/a/1330366
if [ -f "$APPDIR" ] && [ ! -L "$APPDIR" ]; then
exec 6>&2
exec 2>/dev/null
APPDIR=$(osascript << EOF
tell application "Finder"
set theItem to (POSIX file "${APPDIR}") as alias
if the kind of theItem is "alias" then
get the posix path of ((original item of theItem) as text)
end if
end tell
EOF
)
fi

# Copy
cp -f Assets.car Emacs.icns "$APPDIR/Contents/Resources/"

# Update plist
ICON_NAME="Emacs$1"
PLIST="$APPDIR/Contents/Info.plist"
/usr/libexec/PlistBuddy -c "Set :CFBundleIconName $ICON_NAME" "$PLIST" 2>/dev/null \
|| /usr/libexec/PlistBuddy -c "Add :CFBundleIconName string $ICON_NAME" "$PLIST"

# Clear icon cache and restart Dock to show our new icon
rm /var/folders/*/*/*/com.apple.dock.iconcache
rm -rf /var/folders/*/*/*/com.apple.iconservices*
killall Dock

echo "If the new Emacs icon in the Dock has not changed, restart Emacs to take effect."