Migrating away from .pam_environment

So apparently ~/.pam_environment has been deprecated for several years now; on Arch Linux, ~/.pam_environment stopped being read since 2022-10-20. I guess I have to migrate to environment.d then.

ArchWiki is really helpful, but it took searching for Fcitx on Twitter — because, with my environment variables now unset, the input method isn't working anymore — and stumbling onto this tweet before I learned that this is a thing.

I don't know what the standard for a change to make it onto the Arch Linux news page, but apparently "if you set your environment variables via this method that works on both Wayland and X, your environment variables will cease to take effect" is not breaking enough. I don't know, maybe it really isn't: configuration incompatibilities don't usually make it onto the news page, and the grub one is an exception because it's the bootloader.

It's complicated, I just wish there is some way of learning about a major change in a fundamental component.


Anyways. There are some options here:

Use the system wide /etc/environment instead
I don't have a good way to version control system-wide configuration like I do with user configuration files. There is etckeeper, sure, but it attempts to keep track of every config file and every change, and I didn't want to fight against that.
Use a Plasma pre-startup script
This is Plasma-specific, and I'd still like to have the option to occasionally DE-hop.
Use ~/.profile or something like it

SDDM sources ~/.profile (for both Xsession and wayland-session) and I'm fine with using something that's SDDM-specific. …Except:

  • It only sources ~/.profile if the shell is not Zsh, csh, tcsh, or Fish. For Zsh, it sources ~/.zprofile instead.
  • It sources ~/.xprofile for all shells… except, as the name suggests, it does not source it for Wayland.

I also want to be shell-agnostic and display-server-agnostic, so… also no.

Use systemd's ~/.config/environment.d
While this only applies to systemd user services, both GNOME and Plasma can be started as systemd user services. The argument against desktop environments having a hard dependency on systemd is mainly to ensure that they continue to work outside of Linux, and I'm personally comfortable to just depend on it.

The migration

The configuration format is documented in environment.d(5).

In ~/.config/environment.d/99-kisaragi.conf (I'm bad at naming):

# The value is "@im=fcitx". Everything after the first "=" is the value.




# ssh with kwallet

Then it's done after a restart.