Skip to content

Commit d8bc0eb

Browse files
committed
fix: name AppImage desktop entry after app_id for title bar icon
KWin resolves a window's icon (used by the title bar) on Wayland by matching the app_id to a desktop file of the same name. The app_id is the program name 'OpenShock.Desktop', so install the entry as OpenShock.Desktop.desktop instead of openshock-desktop.desktop. Plasma's task manager matched via StartupWMClass already, which is why only the title bar was affected. Also clean up the old mismatched-name entry.
1 parent 067248f commit d8bc0eb

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

packaging/appimage/AppRun

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,22 @@ fi
2121
# This installs:
2222
# - the icon into the user icon theme, and
2323
# - a .desktop entry (which also registers the openshock:// URL scheme handler).
24-
# Both are needed so the running window has the right icon: under Wayland (KDE/GNOME)
25-
# there is no _NET_WM_ICON, so the compositor resolves the taskbar/titlebar icon by
26-
# matching the window app_id (the program name, "OpenShock.Desktop") to a .desktop
27-
# entry and loading its Icon= name from the icon theme.
24+
# The .desktop file is named after the window app_id (the program name,
25+
# "OpenShock.Desktop"). This matters under Wayland (KDE/GNOME), where there is no
26+
# _NET_WM_ICON: the compositor resolves the window icon by matching the app_id to a
27+
# desktop file *of the same name* and loading its Icon= from the icon theme. Naming
28+
# the file to match the app_id is what makes the title bar icon resolve, not just
29+
# the taskbar (which Plasma also matches via StartupWMClass).
2830
if [ -n "${APPIMAGE:-}" ]; then
2931
data_dir="${XDG_DATA_HOME:-${HOME}/.local/share}"
3032
apps_dir="${data_dir}/applications"
3133
icon_dir="${data_dir}/icons/hicolor/512x512/apps"
32-
handler_file="${apps_dir}/openshock-desktop.desktop"
34+
handler_file="${apps_dir}/OpenShock.Desktop.desktop"
3335
icon_src="${HERE}/usr/share/icons/hicolor/512x512/apps/openshock-desktop.png"
3436

3537
changed=0
3638

37-
# Install the icon under both the .desktop Icon= name and the window app_id
38-
# (the program name, "OpenShock.Desktop"). KWin resolves the *taskbar* icon via
39-
# the .desktop Icon=, but the *title bar* looks the icon up in the theme by the
40-
# window app_id directly, so the theme needs an entry under that name too.
39+
# Install the icon under both the .desktop Icon= name and the window app_id name.
4140
if [ -e "${icon_src}" ]; then
4241
for icon_name in openshock-desktop OpenShock.Desktop; do
4342
if [ ! -e "${icon_dir}/${icon_name}.png" ]; then
@@ -48,6 +47,12 @@ if [ -n "${APPIMAGE:-}" ]; then
4847
done
4948
fi
5049

50+
# Remove the legacy mismatched-name entry from earlier versions, if present.
51+
if [ -e "${apps_dir}/openshock-desktop.desktop" ]; then
52+
rm -f "${apps_dir}/openshock-desktop.desktop"
53+
changed=1
54+
fi
55+
5156
if [ ! -e "${handler_file}" ]; then
5257
mkdir -p "${apps_dir}"
5358
cat > "${handler_file}" <<EOF
@@ -62,7 +67,7 @@ MimeType=x-scheme-handler/openshock;
6267
StartupWMClass=OpenShock.Desktop
6368
EOF
6469
command -v xdg-mime >/dev/null 2>&1 && \
65-
xdg-mime default openshock-desktop.desktop x-scheme-handler/openshock 2>/dev/null || true
70+
xdg-mime default OpenShock.Desktop.desktop x-scheme-handler/openshock 2>/dev/null || true
6671
changed=1
6772
fi
6873

0 commit comments

Comments
 (0)