-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Setting Environmental Variables
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.
You can set environment variables through pam_env
, however they will be set system-wide, including across different sessions and users.
There are two ways you can configure PAM to load environment variables, by editing /etc/security/pam_env.conf
or /etc/environment
.
Example for /etc/security/pam_env.conf
(QT_QPA_PLATFORMTHEME
being the variable we want to edit, qt5ct
being the value we want to set):
QT_QPA_PLATFORMTHEME DEFAULT=qt5ct
Example for /etc/environment
consisting of the same variable/value:
QT_QPA_PLATFORMTHEME=qt5ct
You could also edit ~/.pam_environment
the same way you would with /etc/environment
, however that is deprecated since PAM 1.5.0 and will likely be removed at some point in the future. Therefore, this method is discouraged. See their changelog.
For more information about this approach, see this ArchWiki page.
Technically, you could set them in your sway config.
If you launch sway from your login shell, your ~/.zprofile or ~/.profile should work.
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