Order the environment import before Sunshine starts

The previous fix added DISPLAY to the import but left it as a separate
exec line. sway runs exec lines asynchronously and does not order them, so
Sunshine won the race every time — it started in the same second as the
compositor, before DISPLAY existed in the manager environment, and passed
no DISPLAY to the apps it launched. Steam still failed with "Unable to
open a connection to X" while Xwayland was up and the manager environment
looked correct, which is what made it confusing.

One exec with && instead of two.

The earlier verification was wrong for the same reason: I launched Steam
by hand with DISPLAY=:0 set, which tested Xwayland rather than the path
Sunshine actually uses. Re-verified properly by launching Steam in a shell
carrying only the environment read out of Sunshine's own /proc entry.
This commit is contained in:
2026-09-14 16:04:13 -04:00
parent f4200b6a69
commit 425893d516
+8 -2
View File
@@ -16,8 +16,14 @@ xwayland force
# Sunshine is a systemd user unit and inherits nothing from this session, so
# hand it the display variables before starting it.
exec systemctl --user import-environment WAYLAND_DISPLAY DISPLAY XDG_CURRENT_DESKTOP
exec systemctl --user start sunshine.service
#
# ONE exec with &&, not two. sway runs exec lines asynchronously and does not
# order them, so as two separate lines Sunshine won every time: it started in
# the same second as the compositor, before DISPLAY was imported, and passed no
# DISPLAY to the apps it launched. Steam then failed with "Unable to open a
# connection to X" even though Xwayland was up and the manager environment was
# correct.
exec systemctl --user import-environment WAYLAND_DISPLAY DISPLAY XDG_CURRENT_DESKTOP && systemctl --user start sunshine.service
# Input arrives from the Moonlight client, so keybinds are worth having even
# though nobody is sitting at this machine. Without them the Desktop app