Skip to content

fix: update WM_CLASS on linux#4439

Open
opi3636 wants to merge 1 commit intopear-devs:masterfrom
opi3636:master
Open

fix: update WM_CLASS on linux#4439
opi3636 wants to merge 1 commit intopear-devs:masterfrom
opi3636:master

Conversation

@opi3636
Copy link
Copy Markdown

@opi3636 opi3636 commented Apr 26, 2026

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Fixed application identification on Linux systems for both X11 and Wayland desktop environments.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 26, 2026

📝 Walkthrough

Walkthrough

Updates the Electron app naming configuration on Linux by replacing an escaped WM_CLASS string with the explicit application identifier com.github.th_ch.pear_music. The comment clarifies the override applies to both X11 and Wayland display servers.

Changes

Cohort / File(s) Summary
Linux App Naming Configuration
src/index.ts
Changed app.setName() override from escaped WM_CLASS/icon-name format to explicit com.github.th_ch.pear_music identifier; updated accompanying comment to reflect X11 and Wayland applicability.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A name so clear, no escapes in sight,
From twisted strings to format bright,
The pear hops forward with identity true,
On Wayland and X11 alike, shiny and new! 🍐✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: updating WM_CLASS on Linux from an escaped string to an explicit value.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fd6afc79-e42e-4f13-a6ac-cc45a47036ce

📥 Commits

Reviewing files that changed from the base of the PR and between 7b1c574 and 288edbd.

📒 Files selected for processing (1)
  • src/index.ts

Comment thread src/index.ts
Comment on lines +129 to +130
// Overrides WM_CLASS for X11 and Wayland to correspond to icon filename
app.setName('com.github.th_ch.pear_music');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 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:


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).

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.

1 participant