Skip to content

Setting Environmental Variables

RJDan edited this page Jan 20, 2022 · 6 revisions

How you set variables will depend on how sway was started. The explanation below was based on these sources

Environment variables are inherited from the process that starts sway. You need to set variables there.

Some of the possible options are:

  • login manager: check the documentation.
  • login shell: export them there before launching sway.
  • user service: use the EnvironmentFile= key and an environment file.

Login Manager

PAM

Set environment variables specific to user session in the $HOME/.pam_environment. That gets them set right on log in and would work for most methods of launching sway. Note: these variables will be set in non-sway sessions too.

For more info: man 8 pam_env

Set the Sway Config

Technically, you could set them in your sway config.

Login Shell

If you launch sway from my login shell, your ~/.zprofile or ~/.profile should work.

User Service

You can set variables using the environment.d. Environment variables set there will be read by the --user systemd, and since everything is started in its hierarchy variables will properly propagate. This will not work with some login managers.

For more info: man environment.d

Example with sddm as login manager