From 337311bdc8354adc6acb9a232a7cca615f77e0d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=82=B3?= Date: Fri, 13 Feb 2026 22:51:07 +0800 Subject: [PATCH] linux: Name desktop file correctly during bundle (#45508) Closes #45507 There have been 5+ PRs attempting to fix Linux desktop icon association by adding `StartupWMClass` back to the `.desktop.in` template (#15763, #20644, #23459, #33019, #37962), all closed because `StartupWMClass` is an X11-specific key that GNOME happens to misuse on Wayland, and the correct fix per the FreeDesktop spec is to name the `.desktop` file to match the app's Wayland `app_id` / X11 `WM_CLASS`. Refer: https://github.com/zed-industries/zed/issues/12707#issuecomment-2168742761 The root cause is that `bundle-linux` was never updated to produce the correct filename in the tarball. The only consumers of the tarball's desktop file are `install.sh` and manual extractors. So this fix is for people who download the tarball and extract it without `install.sh`. The docs already tell them to rename, but as @wcbing points out, not everyone reads that carefully. We are now making `bundle-linux` produce the correctly named desktop file from the start. Release Notes: - N/A --------- Co-authored-by: Smit Barmase --- docs/src/linux.md | 2 +- script/bundle-linux | 8 ++++++-- script/install.sh | 8 +++++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/docs/src/linux.md b/docs/src/linux.md index dc8403c64b6df9bd2741af3b3e6b7358e3a8e705..049f77be3d55ca95f89fde928c7a4fd273ecc035 100644 --- a/docs/src/linux.md +++ b/docs/src/linux.md @@ -91,7 +91,7 @@ ln -sf ~/.local/zed.app/bin/zed ~/.local/bin/zed If you'd like integration with an XDG-compatible desktop environment, you will also need to install the `.desktop` file: ```sh -cp ~/.local/zed.app/share/applications/zed.desktop ~/.local/share/applications/dev.zed.Zed.desktop +install -D ~/.local/zed.app/share/applications/dev.zed.Zed.desktop -t ~/.local/share/applications sed -i "s|Icon=zed|Icon=$HOME/.local/zed.app/share/icons/hicolor/512x512/apps/zed.png|g" ~/.local/share/applications/dev.zed.Zed.desktop sed -i "s|Exec=zed|Exec=$HOME/.local/zed.app/libexec/zed-editor|g" ~/.local/share/applications/dev.zed.Zed.desktop ``` diff --git a/script/bundle-linux b/script/bundle-linux index 4f5c9f6e7eeb9875346d172dd8d0d2d5d0c2bd27..4e58ac315bd231fd4ae9208abbc15007abc30631 100755 --- a/script/bundle-linux +++ b/script/bundle-linux @@ -164,17 +164,21 @@ export APP_ICON="zed" export APP_ARGS="%U" if [[ "$channel" == "preview" ]]; then export APP_NAME="Zed Preview" + APP_ID="dev.zed.Zed-Preview" elif [[ "$channel" == "nightly" ]]; then export APP_NAME="Zed Nightly" + APP_ID="dev.zed.Zed-Nightly" elif [[ "$channel" == "dev" ]]; then export APP_NAME="Zed Devel" + APP_ID="dev.zed.Zed-Dev" else export APP_NAME="Zed" + APP_ID="dev.zed.Zed" fi mkdir -p "${zed_dir}/share/applications" -envsubst < "crates/zed/resources/zed.desktop.in" > "${zed_dir}/share/applications/zed$suffix.desktop" -chmod +x "${zed_dir}/share/applications/zed$suffix.desktop" +envsubst < "crates/zed/resources/zed.desktop.in" > "${zed_dir}/share/applications/$APP_ID.desktop" +chmod +x "${zed_dir}/share/applications/$APP_ID.desktop" # Copy generated licenses so they'll end up in archive too cp "assets/licenses.md" "${zed_dir}/licenses.md" diff --git a/script/install.sh b/script/install.sh index 1718b1d28284c80cf4d6eb26f6a433d0c2c6e35b..9c8df5aabf2a2b51adf4762e4210c8b70af3edc9 100755 --- a/script/install.sh +++ b/script/install.sh @@ -129,7 +129,13 @@ linux() { # Copy .desktop file desktop_file_path="$HOME/.local/share/applications/${appid}.desktop" - cp "$HOME/.local/zed$suffix.app/share/applications/zed$suffix.desktop" "${desktop_file_path}" + src_dir="$HOME/.local/zed$suffix.app/share/applications" + if [ -f "$src_dir/${appid}.desktop" ]; then + cp "$src_dir/${appid}.desktop" "${desktop_file_path}" + else + # Fallback for older tarballs + cp "$src_dir/zed$suffix.desktop" "${desktop_file_path}" + fi sed -i "s|Icon=zed|Icon=$HOME/.local/zed$suffix.app/share/icons/hicolor/512x512/apps/zed.png|g" "${desktop_file_path}" sed -i "s|Exec=zed|Exec=$HOME/.local/zed$suffix.app/bin/zed|g" "${desktop_file_path}" }