cobalt
cobalt copied to clipboard
Force wayland if it's the only thing available
Hi! I'd like to propose a new functionality for cobalt which seems quite in line with its goals.
I'm currently working on updating the Slackflatpak package to run under wayland if it's the only thing available. That is:
- If
DISPLAYis unset. - If
WAYLAND_DISPLAYis set.
This means that the application will use wayland for users where they either:
- Are using Wayland but no XWayland.
- Have toggled a a flatpak override to disallow x11 and allowed wayland
Note that this has no impact on users using X11, using XWayland and/or using no special overrides. It also only really has any impact on scenarios where the application would otherwise crash on startup.
Do you think this tiny logic and addition of these flags would make sense in cobalt? The sh-equivalent in a wrapper script is:
if [ -z "$DISPLAY" ] && [ -n "$WAYLAND_DISPLAY" ]; then
EXTRA_ARGS="--enable-features=UseOzonePlatform,WebRTCPipeWireCapturer --ozone-platform=wayland"
else
EXTRA_ARGS=""
fi
zypak-wrapper /app/bin/my-app $EXTRA_ARGS "$@"
Hmm I'm not entirely sure about this... I've definitely seen cases where XWayland not starting is a bug or configuration mistake, and thus this would end up essentially masking the issue with slightly different, potentially undesired behavior. Or, in other words:
- The type of person who is going to be intentionally disabling XWayland would likely know to pass the flags.
- The type of person who accidentally has non-functioning XWayland will have a "working" application, except several things are subtly / non-obviously different.
All this being said...in Cobalt we already have logic for showing warning dialogs and such, I'd imagine it could be extended? This would still have to be a config option, though, since some apps have either old Electron versions missing wayland support, or versions with support broken enough that trying it is worthless.
Most Electron flatpaks don't pass the Wayland socket out-of-the-box, so even if XWayland failed to start and DISPLAY was unset, WAYLAND_DISPLAY still won't be set, and we wouldn't be falling back to wayland unexpectednly. Note that both conditions must be met, so the user needs to have activated socket=wayland for this proposal to take any effect.
The approach here is very much opt-in (the user has to take manual action to enable it) and convention-based: "force using wayland only if the user manually disabled socket=x11 and enabled socket=wayland".
Just for the record, in the past I've tried these approaches that don't really work:
- Manually passing flags does work, they have to be passed at runtime each time the application is run.
- Some package read an overrides file on-disk, but the mechanism that flatpak uses to mount these doesn't work with symlinks, so this doesn't work with most dotfiles manager since those operate using symlink. This makes managing one's setup very hard, and just brings into scope another set of issues.
- Patching the
.desktopfile is also tricky since this needs to be re-done after each upgrade, and flatpak has no concept of post-install hooks or anything alike.
Another approach that I do think could work, would be to just add the flags in this proposal when an environment variable like COBALT_FORCE_WAYLAND=1 is set. Or maybe even just COBALT_EXTRA_FLAGS=="--enable-features=UseOzonePlatform,WebRTCPipeWireCapturer --ozone-platform=wayland". Flatpak overrides make it very easy and maintainable for users to defined their own extra environment flags.