fix: update WM_CLASS on linux#4439
Conversation
📝 WalkthroughWalkthroughUpdates the Electron app naming configuration on Linux by replacing an escaped WM_CLASS string with the explicit application identifier Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/index.ts`:
- Around line 129-130: Update the WM_CLASS value passed to app.setName to use
lowercase hyphens and match the Windows identifier pattern: replace
app.setName('com.github.th_ch.pear_music') with
app.setName('com.github.th-ch.pear-music'); also verify and align any other
platform identifiers (e.g., the Windows identifier
'com.github.th-ch.youtube-music') so the app name/identifier is consistent
across platforms and reflects the intended product name (change other
occurrences if this is a rename).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
| // Overrides WM_CLASS for X11 and Wayland to correspond to icon filename | ||
| app.setName('com.github.th_ch.pear_music'); |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Verify desktop file and icon existence matching the new identifier
# Check for desktop files
echo "=== Searching for desktop files ==="
fd -e desktop -x echo "Found: {}"
# Check for icon files matching the identifier
echo -e "\n=== Searching for icon files matching identifier ==="
fd -i "pear" --type f -e png -e svg -e ico -e icns | head -20
# Check desktop file content if exists
echo -e "\n=== Checking desktop file content ==="
fd "com.github.th_ch.pear_music.desktop" -x cat {}
# Also check for any youtube-music references
echo -e "\n=== Checking for youtube-music references in desktop files ==="
fd -e desktop -x grep -l "youtube-music" {}Repository: pear-devs/pear-desktop
Length of output: 259
🌐 Web query:
What is the correct WM_CLASS identifier format for Electron apps on Linux desktop files?
💡 Result:
The correct WM_CLASS identifier format for Electron apps on Linux desktop files is the lowercase, hyphenated version of the application's name (from package.json "name" field or set via app.setName), matching the actual WM_CLASS property set by Electron on the running windows. In the .desktop file, use StartupWMClass= followed by this exact string (case-sensitive match to xprop WM_CLASS(STRING) second value). To determine it: 1. Run the Electron app. 2. Use xprop | grep WM_CLASS and click the window. 3. WM_CLASS(STRING) = "instance", "class" — the "class" value (second one) is the identifier. For packaged apps (e.g., via electron-builder): - Defaults to lowercase of package.json "name" (e.g., "beekeeper-studio"). - Use "desktopName": "appname.desktop" in package.json; builders strip .desktop for StartupWMClass=appname. - Override explicitly in build config: "linux": { "desktop": { "StartupWMClass": "your-wmclass" } }. Electron derives WM_CLASS from app name (lowercase, normalized), while productName is display name. Mismatch causes icon/taskbar issues. Always verify with xprop for exact match.
Citations:
- 1: Wrong StartupWMClass being set in the .desktop file for linux builds electron-userland/electron-builder#4974
- 2: Wayland app_id should be normalized to match wm_class electron/electron#48391
- 3: Use desktopName from package.json for StartupWMClass in Linux desktop entries electron-userland/electron-builder#9574
- 4: [Bug]: There is no way to get a custom WM_CLASS on electron app Windows electron/electron#33155
- 5: [Bug]: There is no way to get a custom WM_CLASS on electron app Windows electron/electron#33155
Use hyphens in WM_CLASS identifier to match Electron Linux conventions.
The identifier com.github.th_ch.pear_music uses underscores, which violates the standard Electron/Linux convention for WM_CLASS values. According to Electron builder standards, WM_CLASS should use lowercase, hyphenated format (e.g., com.github.th-ch.pear-music). This should also align with the Windows identifier format at line 663 which uses hyphens (com.github.th-ch.youtube-music).
Additionally, the application name differs between platforms: pear_music (Linux) vs youtube-music (Windows). Clarify whether this is an intentional rebrand or an incomplete migration, and ensure the identifier is consistent across all platforms using the correct format: com.github.th-ch.pear-music.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/index.ts` around lines 129 - 130, Update the WM_CLASS value passed to
app.setName to use lowercase hyphens and match the Windows identifier pattern:
replace app.setName('com.github.th_ch.pear_music') with
app.setName('com.github.th-ch.pear-music'); also verify and align any other
platform identifiers (e.g., the Windows identifier
'com.github.th-ch.youtube-music') so the app name/identifier is consistent
across platforms and reflects the intended product name (change other
occurrences if this is a rename).
Summary by CodeRabbit
Release Notes