Skip to content

feat(linux): add wrapper script to force XWayland and support user flags#507

Merged
gabrielste1n merged 2 commits into
OpenWhispr:mainfrom
DamianPala:feat/linux-wrapper-script
Apr 2, 2026
Merged

feat(linux): add wrapper script to force XWayland and support user flags#507
gabrielste1n merged 2 commits into
OpenWhispr:mainfrom
DamianPala:feat/linux-wrapper-script

Conversation

@DamianPala

@DamianPala DamianPala commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Electron can't position overlay windows, control always-on-top, or prevent focus stealing on Wayland. This is an xdg-shell protocol limitation, not a compositor bug, and it hits every compositor the same way (electron#48749, electron#12445). Electron's own docs say to use --ozone-platform=x11 for apps that need these capabilities.

appendSwitch() from PR #470 doesn't work on Electron 39+ because the ozone platform is picked during Chromium init, before any JS runs. VS Code ran into the same thing (microsoft/vscode#135191).

This adds an afterPack hook that wraps the Linux binary in a bash script. Same approach as the Chromium wrapper script used by Chrome and Brave on Linux (google-chrome calls chrome, brave-browser calls brave). The wrapper forces XWayland on Wayland sessions and reads user flags from ~/.config/open-whispr-flags.conf (one per line, # comments, same format as chrome-flags.conf).

Supersedes the self-relaunch from PR #495 (no extra PID, Ctrl+C works, no startup overhead, user-configurable flags).

Changes

scripts/afterPack.js, electron-builder hook (Linux only). Renames open-whispr to open-whispr-app, writes a bash wrapper as open-whispr that:

  1. Adds --ozone-platform=x11 when XDG_SESSION_TYPE=wayland
  2. Reads ~/.config/open-whispr-flags.conf for user flags (one per line, # comments)
  3. exec -a "$0" into the real binary (replaces the process, ps shows open-whispr)

Putting --ozone-platform=wayland in flags.conf overrides the default (last flag wins).

Test plan

Build:

  • npm run build:linux -- --publish never --linux dir deb rpm
  • file dist/linux-unpacked/open-whispr shows bash script
  • file dist/linux-unpacked/open-whispr-app shows ELF
  • dpkg -c *.deb | grep open-whispr shows both files in /opt/OpenWhispr/

XWayland (verified with xlsclients | grep -i whispr and ps aux | grep open-whispr showing --ozone-platform=x11):

  • Ubuntu 24.04 LTS, GNOME Wayland, deb, XWayland, bubble in corner
  • Kubuntu 24.04 LTS, KDE Plasma Wayland, deb, XWayland, bubble in corner
  • Kubuntu 25.10, KDE Plasma Wayland, unpacked + deb, XWayland
  • Fedora 41 KDE spin, KDE Plasma Wayland, rpm, XWayland, bubble in corner

flags.conf:

  • --ozone-platform=wayland in flags.conf forces native Wayland (last flag wins)
  • Removing the file falls back to XWayland

No regression:

  • X11 session (Kubuntu 24.04 KDE): no --ozone-platform flag added
  • macOS/Windows: unaffected (hook returns early on non-Linux)

Refs #495, #470

electron-builder afterPack hook wraps the Linux binary in a bash
script that forces XWayland on Wayland sessions (overlay positioning
and focus control require X11) and reads user flags from
~/.config/open-whispr-flags.conf.
@DamianPala
DamianPala marked this pull request as ready for review March 26, 2026 12:13
The appendSwitch code is now a dev-mode fallback; packaged builds
use the afterPack wrapper script to force XWayland.
@gabrielste1n
gabrielste1n self-requested a review April 2, 2026 03:06
@gabrielste1n
gabrielste1n merged commit 1c32a0c into OpenWhispr:main Apr 2, 2026
6 checks passed
charian47 pushed a commit to charian47/openwhispr that referenced this pull request Apr 25, 2026
…script

feat(linux): add wrapper script to force XWayland and support user flags
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