diff --git a/README.md b/README.md index a3a9afce..c5d2a4c6 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,8 @@ scoop install stroke Or grab an installer from [Releases](https://github.com/stroke-app/stroke/releases): `.dmg` for macOS (Apple Silicon or Intel), `-setup.exe` for Windows, `.deb` (Ubuntu 22.04+, Debian 12+), `.rpm` (Fedora 41+, RHEL 10) or `.AppImage` (Arch and any distro with glibc 2.35+) for Linux. +The AppImage runs through XWayland by default. To try native Wayland, start it with `STROKE_WAYLAND=1`. + **Stroke Nightly** is built every night from the `nightly` branch and installs as a separate app beside Stroke, with its own settings, so you can try what's coming without risking your setup: [download the nightly](https://github.com/stroke-app/stroke/releases/tag/nightly). It updates itself every night something lands. If macOS blocks the first launch, run `xattr -cr /Applications/Stroke.app`. If Windows SmartScreen warns, choose **More info → Run anyway**. diff --git a/scripts/appimage-strip-host-libs.sh b/scripts/appimage-strip-host-libs.sh index 3d628388..630c29c9 100755 --- a/scripts/appimage-strip-host-libs.sh +++ b/scripts/appimage-strip-host-libs.sh @@ -14,6 +14,12 @@ # Tested on Arch, Fedora 41/45, Debian 12/13 and Ubuntu 22.04/24.04. # Issue: https://github.com/stroke-app/stroke/issues/112 # +# It also lets the AppImage run on native Wayland when asked. linuxdeploy's +# GTK hook hard-sets GDK_BACKEND=x11, so the window always went through +# XWayland and a GDK_BACKEND=wayland on the command line was ignored. X11 stays +# the default (it is the fallback for the WebKit EGL_BAD_ALLOC crash some +# Wayland setups hit); STROKE_WAYLAND=1 opts into the native backend. +# # The image is repacked with its own runtime and the same squashfs settings, # so nothing else about the AppImage changes. Needs squashfs-tools. @@ -44,20 +50,33 @@ find_excluded() { find "$root" \( -type f -o -type l \) \( "${args[@]}" \) "$@" } +changed=0 removed="$(find_excluded -print | sed "s|^$root/||" | sort)" -if [ -z "$removed" ]; then - echo "appimage: no host-only libraries bundled, nothing to do" - exit 0 +if [ -n "$removed" ]; then + find_excluded -delete + echo "appimage: removed" + printf ' %s\n' $removed + changed=1 fi -find_excluded -delete -echo "appimage: removed" -printf ' %s\n' $removed if [ -n "$(find_excluded -print)" ]; then echo "appimage: host-only libraries still present" >&2 exit 1 fi +# X11 by default, native Wayland with STROKE_WAYLAND=1. +hook="$root/apprun-hooks/linuxdeploy-plugin-gtk.sh" +if [ -f "$hook" ] && grep -qE '^export GDK_BACKEND=x11' "$hook"; then + sed -i -E 's|^export GDK_BACKEND=x11.*$|if [ "${STROKE_WAYLAND:-}" = 1 ]; then export GDK_BACKEND=wayland; else export GDK_BACKEND=x11; fi|' "$hook" + echo "appimage: GDK_BACKEND=x11 unless STROKE_WAYLAND=1" + changed=1 +fi + +if [ "$changed" = 0 ]; then + echo "appimage: nothing to change" + exit 0 +fi + # Same compression and block size linuxdeploy's appimagetool uses. mksquashfs "$root" "$work/fs.squashfs" -root-owned -noappend -comp zstd -b 131072 -no-progress -quiet cat "$work/runtime" "$work/fs.squashfs" > "$work/out.AppImage"