UP  |  HOME

pam_env

Previously I used ~/.profile for setting environment variables in X.

With Wayland the best way to do it on a user file level seems to be ~/.pam_environment, but this isn't enabled by default. There are some security implications to consider: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=989919#20

To enable it I modified /etc/pam.d/common-session since it seems to be included in most other pam configs. It was suggested that pam_env.so be loaded last, but common-session often gets loaded before keyring modules, and common-password. In any case I added it at the end before the final comment. It looks like:

Listing 1: /etc/pam.d/common-session (excerpt)
session required    pam_env.so user_readenv=1
# end of pam-auth-update config

I just put all KEY=​VALUE entries one per line in ~/.pam_environment. Now any session that loads common-session should get those environment variables.

Listing 2: ~/.pam_environment
GTK_CSD=0
MPD_HOST=hostname.domain
MPD_PORT=6600
STEAM_FRAME_FORCE_CLOSE=1
PDFVIEWER=atril
PDFVIEWER_texdoc=atril
TEXDOC_VIEWER_PDF=atril
CALIBRE_USE_SYSTEM_THEME=1
GTK_OVERLAY_SCROLLING=0
# Using qt5ct for dark themes, but wayland would be nice if I could sort that TODO
QT_QPA_PLATFORMTHEME=qt5ct
LC_COLLATE=C
MOZ_ENABLE_WAYLAND=1
MOZ_USE_XINPUT2=1
GVIM_ENABLE_WAYLAND=1
# Can't use wayland for GDK because GTK Vim needs X stuff
#GDK_BACKEND=wayland