That’s right, ReGreet makes this very easy by allowing environment variables to be set right in the config. I don’t believe SDDM makes this quite as easy so you’ll have to cook up something else.
Just to clarify, these configs are importing environment variables into the user environment (which is different than setting environment variables system-wide).
A simple solution would to be to create a custom session file that sets your environment variables for you, similar to how you would set them in a desktop entry (see https://wiki.archlinux.org/title/Desktop_entries#Modify_environment_variables).
You can put a custom session file in /usr/local/share/wayland-sessions (so it doesn’t get overwritten when the Sway package gets updated). First create the directory if it doesn’t already exist:
sudo mkdir -p /usr/local/share/wayland-sessions
Then copy over the existing session file:
sudo cp /usr/share/wayland-sessions/sway.desktop /usr/local/share/wayland-sessions/
Open the new file with an editor and add your environment variables to the Exec line with env.
[Desktop Entry]
Name=Sway
Comment=An i3-compatible Wayland compositor
Exec=env XDG_CURRENT_DESKTOP=sway sway
Type=Application
DesktopNames=sway
Another approach would be to create a wrapper script that sets the environment variables before starting Sway as described in the Greetd wiki: https://man.sr.ht/~kennylevinsen/greetd/#how-to-set-xdg_session_typewayland
Then call the wrapper script on the Exec line of your custom session file (instead of calling sway directly).
[Desktop Entry]
Name=Sway
Comment=An i3-compatible Wayland compositor
Exec=/usr/local/bin/sway-run
Type=Application
DesktopNames=sway
Either way should work fine. ![]()
