-
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e9916ff
:hammer: Wayland support for electron apps
noonsleeper 08e2b43
:bug: Fix KDE wayland check
noonsleeper 86de662
:wrench: Add EDITOR_RUNTIME_ARGS environment variable usage example
noonsleeper fc64d54
:hammer: Check for wayland socket
noonsleeper 138f9a3
:bug: Fix wrong variable name
noonsleeper 75d37e1
:wrench: match the existing format
noonsleeper File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,9 +7,27 @@ 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_DISPLAY} == "/run/flatpak/wayland-"* ]] || [[ -e "${XDG_RUNTIME_DIR}/${WAYLAND_DISPLAY}" ]] && [[ "wayland" == "${XDG_SESSION_TYPE}" ]] | ||
then | ||
DISPLAY_SERVER_ARGS="--ozone-platform-hint=auto --enable-wayland-ime --enable-features=WaylandWindowDecorations" | ||
if [ -c /dev/nvidia0 ] | ||
then | ||
DISPLAY_SERVER_ARGS="${DISPLAY_SERVER_ARGS} --disable-gpu-sandbox" | ||
fi | ||
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
} | ||
|
||
if [ ! -f "${FIRST_RUN}" ]; then | ||
|
Oops, something went wrong.
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.
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?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.
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.
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.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
reportssocket
or if it fails (ie. whennosocket=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 ifwayland-*
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 fileswayland-0, wayland-0.lock
too (fortunately there is only onewayland-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.
@bbhtt, @gasinvein
I'm still on Silverblue F39 and
WAYLAND_DISPLAY
is reporting onlywayland-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: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.
This also works I think.