this post was submitted on 18 Jun 2025
2 points (75.0% liked)

swaywm

444 readers
18 users here now

dedicated to the Sway window manager, a drop-in replacement for the i3 window manager, but for Wayland instead of X11.

founded 5 years ago
MODERATORS
 

If you're new to Wayland as I am, you haven't failed to be frustrated by the greeter / Sway not sourcing any of the usual X or profile configuration files. In i3, you export your variables in .profile and they're set everywhere for the whole session. Not so in Sway.

That means if you have a custom PATH or some exported variable you would like to define session-wide - setting QT_QPA_PLATFORMTHEME so all QT apps use the correct theme in Gnome for instance - you can't. Not the usual way anyway.

Those variables are set if you run a terminal with the shell in login mode, if they're defined in /etc/profile or .profile, but not if you run the program directly in Sway, such as wofi / rofi for example, or any program that needs an environment variable that isn't set.

Here's how to set environment variables for the entire session in Sway:

  • Choose a greeter that understands systemd's environment.d. Unfortunately, there aren't very many. GDM and Plasma are the only two that I know of that do.

  • Define your environment variables in ~/.config/environment.d/envvars.conf. You can define them the usual way like in profile, including extending variables like $PATH, e.g.:

    QT_QPA_PLATFORMTHEME=qt5ct
    PATH=$PATH:/usr/games:~/scripts
    
  • Either reboot for the changes to take effect, or run systemctl --user daemon-reload to get systemd to parse your file again, then log out and back in as with Xorg.

Unfortunately, simply logging out and back in without informing systemd of your changes isn't enough - which is why you need to reboot if you don't do the daemon-reload command.

That's it!

Not too obvious, and not great. But in fairness, it's no more confusing than the mess of shell and X configuration files that existed before systemd and Wayland. It's just that systemd and Wayland are an entirely different complete trainwreck that takes getting used to ๐Ÿ˜ƒ

you are viewing a single comment's thread
view the rest of the comments
[โ€“] [email protected] 2 points 2 days ago (1 children)

Much less troublesome to ditch the display managers, log in from the tty and run sway from a script such as mine

[โ€“] [email protected] 1 points 2 days ago

I don't find it convenient at all personally. I haven't done anything substantial in the console for at least 2 decades, so I never have any reason to log into the console other than to rescue a machine. Therefore, if the only thing I need the console for is to type "sway", and then having to log out twice, I'd much rather have a DM.

But to each his own ๐Ÿ˜ƒ