feat(linux): add wrapper script to force XWayland and support user flags#507
Merged
gabrielste1n merged 2 commits intoApr 2, 2026
Merged
Conversation
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
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
self-requested a review
April 2, 2026 03:06
gabrielste1n
approved these changes
Apr 2, 2026
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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=x11for 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
afterPackhook that wraps the Linux binary in a bash script. Same approach as the Chromium wrapper script used by Chrome and Brave on Linux (google-chromecallschrome,brave-browsercallsbrave). The wrapper forces XWayland on Wayland sessions and reads user flags from~/.config/open-whispr-flags.conf(one per line,#comments, same format aschrome-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). Renamesopen-whisprtoopen-whispr-app, writes a bash wrapper asopen-whisprthat:--ozone-platform=x11whenXDG_SESSION_TYPE=wayland~/.config/open-whispr-flags.conffor user flags (one per line,#comments)exec -a "$0"into the real binary (replaces the process,psshowsopen-whispr)Putting
--ozone-platform=waylandin flags.conf overrides the default (last flag wins).Test plan
Build:
npm run build:linux -- --publish never --linux dir deb rpmfile dist/linux-unpacked/open-whisprshows bash scriptfile dist/linux-unpacked/open-whispr-appshows ELFdpkg -c *.deb | grep open-whisprshows both files in/opt/OpenWhispr/XWayland (verified with
xlsclients | grep -i whisprandps aux | grep open-whisprshowing--ozone-platform=x11):flags.conf:
--ozone-platform=waylandin flags.conf forces native Wayland (last flag wins)No regression:
--ozone-platformflag addedRefs #495, #470