-
Notifications
You must be signed in to change notification settings - Fork 13
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
Conversation
Hello @gasinvein, can you give us a timeline for this PR? Thx |
Hello, sorry for the delay and thanks for the contribution. Sadly, I cannot test this myself atm. Did you try to build VSCod[ium] flatpak with this wrapper version and verify that it works as intended? |
editor.sh
Outdated
# 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_DISPLAY} == "/run/flatpak/wayland-"* ]] || [[ -e "${XDG_RUNTIME_DIR}/${WAYLAND_DISPLAY}" ]] && [[ "wayland" == "${XDG_SESSION_TYPE}" ]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't checking if XDG_SESSION_TYPE
is set to wayland
is enough?
if [[ ${WAYLAND_DISPLAY} == "/run/flatpak/wayland-"* ]] || [[ -e "${XDG_RUNTIME_DIR}/${WAYLAND_DISPLAY}" ]] && [[ "wayland" == "${XDG_SESSION_TYPE}" ]] | |
if [[ "wayland" == "${XDG_SESSION_TYPE}" ]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't checking if
XDG_SESSION_TYPE
is set towayland
is enough?
No, under KDE, $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY
will give /run/user/1000//run/flatpak/wayland-0
which is incorrect. That's why @noonsleeper is testing for the prefix /run/flatpak/wayland-
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't checking if XDG_SESSION_TYPE is set to wayland is enough?
Checking for the socket is correct, $XDG_SESSION_TYPE
can stay on wayland even if the finish arg is removed (ie. with --nosocket
) as it is inherited from the environment and has no connection with the active finish args.
/run/user/1000//run/flatpak/wayland-0
Those two should not overlap like that, it should always be /run/flatpak/wayland-{0, 1,...}
You should check for only one of them - preferably for the one /run/flatpak/
only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to make it more sound you can check if stat -c %F /run/flatpak/wayland-0
reports socket
or if it fails (ie. when nosocket=wayland
or not on wayland session).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @bbhtt, to sum up, I only need to check if $WAYLAND_DISPLAY contains wayland-
and also $XDG_SESSION_TYPE == wayland, because flatpak already check if wayland-*
is a socket, is that so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can do if [[ -e "$(echo "/run/flatpak/wayland-"*)" ]]; then echo "yes"; else echo "no"; fi
but it might match multiple files wayland-0, wayland-0.lock
too (fortunately there is only one wayland-0
in /run/flatpak/
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still on Silverblue F39 and WAYLAND_DISPLAY
is reporting only wayland-0
not the full path, I don't check if F40 change that behaviour within gnome 46, but I think other distros like Debian or Ubuntu maybe has the same behaviour for Gnome 45.
Then, if we need to check both at the same time, I come with this:
It is not perfect like you can see, but it comes handy because I don't use or pass that variable to anything, also this check that at least the variable is filled with something that resembles what we are looking for,
Also, I can go with a more accurate regex that only *wayland-?
(to me this will add more complexity to something that doesn't require that, but maybe I'm wrong, I'm open to any advice), what do you think?
Btw, sorry for this wall of text
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be easier to check if WAYLAND_DISPLAY
is an absolute path. If not, then construct the path to the socket using the implicit path. Like:
local display_type=x11
local display_server_args
local wayland_socket
if [ "$XDG_DISPLAY_TYPE" = wayland ] && [ -n "$WAYLAND_DISPLAY" ]; then
if [[ $WAYLAND_DISPLAY =~ ^/ ]]; then
wayland_socket=$WAYLAND_DISPLAY
else
wayland_socket="${XDG_RUNTIME_DIR:-/run/user/${UID}}/${WAYLAND_DISPLAY}"
fi
[ -e "$wayland_socket" ] && display_type=wayland
fi
if [ "$display_type" = wayland ]; then
# Set display_server_args for wayland
else
# Set display_server_args for x11
fi
echo $display_server_args
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another way without using a regex would be [ "${WAYLAND_DISPLAY::1}" = / ]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be easier to check if WAYLAND_DISPLAY is an absolute path. If not, then construct the path to the socket using the implicit path. Like:
This also works I think.
No problem. :) The latest version should include it with the fix for KDE but I haven't test it myself... |
Hi @gasinvein, Can you give me an update about this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
The |
I was using this since nearly the creation of the branch, and at least for codium and codium-insiders it works like a charm. |
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} "$@" |
There was a problem hiding this comment.
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
socket=wayland
is active the parameters to handle wayland decorations is set alsoozone-platform-hint=auto
is setif you override with
nosocket=wayland
forceozone-platform=x11