Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔨 Wayland support for electron apps #23

Merged
merged 6 commits into from
Jun 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,10 @@ You may use the following environment variables to change the behaviour of the i
* `FLATPAK_ISOLATE_PIP` (= `FLATPAK_ISOLATE_PACKAGES`)

* `FLATPAK_PREFER_USER_PIP` (= `FLATPAK_PREFER_USER_PACKAGES`)

* `EDITOR_RUNTIME_ARGS`

Add custom arguments to the editor.

Example `flatpak override --user --env=EDITOR_RUNTIME_ARGS="CUSTOM_ARGS" ...`

25 changes: 24 additions & 1 deletion editor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,32 @@ shopt -s nullglob
FIRST_RUN="${XDG_CONFIG_HOME}/@FLAGFILE_PREFIX@-first-run"
SDK_UPDATE="${XDG_CONFIG_HOME}/@FLAGFILE_PREFIX@-sdk-update-@SDK_VERSION@"

function display_server_args (){
# See https://github.com/flathub/im.riot.Riot/blob/3fdd41c84f40fa1e8e186bade5d832d79045600c/element.sh
# See also https://gaultier.github.io/blog/wayland_from_scratch.html
# and https://github.com/flathub/com.vscodium.codium/issues/321
if [ "wayland" == "${XDG_SESSION_TYPE}" ] && [ -n "${WAYLAND_DISPLAY}" ]; then
if [[ "${WAYLAND_DISPLAY}" =~ ^/ ]]; then
wayland_socket="${WAYLAND_DISPLAY}"
else
wayland_socket="${XDG_RUNTIME_DIR:-/run/user/${UID}}/${WAYLAND_DISPLAY}"
fi
fi

if [ -e "$wayland_socket" ]; then
DISPLAY_SERVER_ARGS="--ozone-platform=wayland --enable-wayland-ime --enable-features=WaylandWindowDecorations"
[ -c /dev/nvidia0 ] && DISPLAY_SERVER_ARGS="${DISPLAY_SERVER_ARGS} --disable-gpu-sandbox"
else
DISPLAY_SERVER_ARGS="--ozone-platform=x11"
fi

echo "${DISPLAY_SERVER_ARGS}"
}

function exec_editor() {
@EXPORT_ENVS@
exec "@WRAPPER_PATH@" @EDITOR_ARGS@ "$@"
# shellcheck disable=SC2046,SC2086
exec "@WRAPPER_PATH@" @EDITOR_ARGS@ $(display_server_args) ${EDITOR_RUNTIME_ARGS} "$@"
gasinvein marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Collaborator

@gasinvein gasinvein Jun 9, 2024

Choose a reason for hiding this comment

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

@noonsleeper Ok, there seems to be one thing I've missed. The wrapper isn't solely for Electron apps, thus electron-specific cli args shouldn't be added unconditionally.
Adding the display server args for electron should be gated by Zypak feature enabled.

}

if [ ! -f "${FIRST_RUN}" ]; then
Expand Down
Loading