Skip to content

Setting Environmental Variables

camoz edited this page May 16, 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

Setting user environment variables via PAM ($HOME/.pam_environment) is deprecated since PAM 1.5.0 and therefore discouraged, see https://github.com/linux-pam/linux-pam/releases/tag/v1.5.0.

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