Skip to content

fix(build): fix missing icon in the dock/dash of Linux DEs#6303

Open
mikelei8291 wants to merge 1 commit into
HMCL-dev:mainfrom
mikelei8291:fix-linux-desktop-icon
Open

fix(build): fix missing icon in the dock/dash of Linux DEs#6303
mikelei8291 wants to merge 1 commit into
HMCL-dev:mainfrom
mikelei8291:fix-linux-desktop-icon

Conversation

@mikelei8291

Copy link
Copy Markdown

The missing StartupWMClass property in the .desktop file is causing the app icon not displaying on the dock/dash of Linux desktop environments.

I'm not sure if there was a better way to retrieve the class name of the Launcher class than setting it as a property in the build.gradle.kts file with a literal string. If you happen to know how to retrieve the class name programmatically, feel free to tell me how to do it and I'll update the PR accordingly. Thank you.

The missing `StartupWMClass` property in the .desktop file is causing
the app icon not displaying on the dock/dash of Linux desktop environments.
@Glavo

Glavo commented Jul 5, 2026

Copy link
Copy Markdown
Member

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds the StartupWMClass property to the generated Linux .desktop file in the Debian package creation task to improve window matching. Feedback suggests replacing dots with hyphens in the launcher class name (e.g., changing org.jackhuang.hmcl.Launcher to org-jackhuang-hmcl-Launcher) because Java GUI applications on Linux use hyphens for their window manager class, which is necessary for the desktop environment to correctly associate the application icon.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Keywords=mc;minecraft;
""".formatted(getCurrentType().getDisplayName(), getLauncherPath(), getIconTargetPath());
StartupWMClass=%s
""".formatted(getCurrentType().getDisplayName(), getLauncherPath(), getIconTargetPath(), getLauncherClassName().get());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

In Java AWT/Swing/JavaFX on Linux, the default WM_CLASS of the window is generated by taking the fully qualified name of the main class and replacing dots ('.') with hyphens ('-'). Therefore, for org.jackhuang.hmcl.Launcher, the actual window's WM_CLASS will be org-jackhuang-hmcl-Launcher. If the .desktop file specifies StartupWMClass=org.jackhuang.hmcl.Launcher (with dots), the desktop environment will fail to match the running window with the .desktop file, and the application icon will still not display correctly on the dock/dash (or a duplicate generic icon will appear). To fix this, we should replace dots with hyphens in the StartupWMClass value.

Suggested change
""".formatted(getCurrentType().getDisplayName(), getLauncherPath(), getIconTargetPath(), getLauncherClassName().get());
""".formatted(getCurrentType().getDisplayName(), getLauncherPath(), getIconTargetPath(), getLauncherClassName().get().replace('.', '-'));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants