Skip to content

Commit

Permalink
snap: Run as native wayland client if possible
Browse files Browse the repository at this point in the history
The new electron versions support wayland natively, this implies
that mailspring can use the native rendering when in a wayland
desktop environment, bringing various benefits including a better
rendering in high DPI displays.

To enable this electron still requires some flags, so add a wrapper
launcher that is used to enable them unless wayland isn't explicitly
disabled.
  • Loading branch information
3v1n0 committed Jan 10, 2024
1 parent 9a7e1a7 commit 08782c7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 9 additions & 0 deletions snap/launcher
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

if [ -n "$WAYLAND_DISPLAY" ] && \
[ "${DISABLE_WAYLAND:-0}" = 0 ] && \
[ "${GDK_BACKEND:-wayland}" = "wayland" ]; then
args="--enable-features=WaylandWindowDecorations --ozone-platform=wayland --use-gl=desktop"
fi

exec "$SNAP/usr/bin/mailspring" $args "${@}"
7 changes: 4 additions & 3 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ parts:
override-build: |
cp -a "$CRAFT_PART_SRC"/* "$CRAFT_PART_INSTALL"
craftctl default
install -m 755 ${CRAFT_PROJECT_DIR}/snap/launcher \
-D ${CRAFT_PART_INSTALL}/bin/mailspring.launcher -v
sed -i 's|Icon=mailspring|Icon=/usr/share/pixmaps/mailspring\.png|' \
$CRAFT_PART_INSTALL/usr/share/applications/Mailspring.desktop
prime:
Expand All @@ -44,7 +46,7 @@ parts:

apps:
mailspring:
command: usr/bin/mailspring --no-sandbox
command: bin/mailspring.launcher --no-sandbox
common-id: mailspring
desktop: usr/share/applications/Mailspring.desktop
extensions: [gnome]
Expand All @@ -53,8 +55,6 @@ apps:
# Correct the TMPDIR path for Chromium Framework/Electron to
# ensure libappindicator has readable resources.
TMPDIR: $XDG_RUNTIME_DIR
# Fallback to XWayland if running in a Wayland session.
DISABLE_WAYLAND: 1
plugs:
- avahi-observe
- browser-support
Expand All @@ -69,3 +69,4 @@ apps:
- pulseaudio
- unity7
- x11
- wayland

0 comments on commit 08782c7

Please sign in to comment.