antidot icon indicating copy to clipboard operation
antidot copied to clipboard

Option to use ~/.pam_environment

Open aidanharris opened this issue 5 years ago • 4 comments

This can be useful for setting environment variables that need to affect your login shell before your login shell has started. For example Zsh allows you to set a $ZDOTDIR variable to modify where it stores its configuration which can be achieved as follows:

~/.pam_environment:

XDG_CONFIG_HOME   DEFAULT=@{HOME}/.config
ZDOTDIR	DEFAULT=${XDG_CONFIG_HOME}/zsh

aidanharris avatar Dec 04 '20 21:12 aidanharris

By "use" do you mean that antidot will store the environment variables in that file so it will be available pre-login? Will it also take affect after login? Or should we duplicate it?

doron-cohen avatar Dec 04 '20 21:12 doron-cohen

By "use" do you mean that antidot will store the environment variables in that file so it will be available pre-login?

Exactly. It'll be available before the login shell has started (or before your graphical session has started if using a display manager like gdm or sddm) and persist afterwards. This is also independent of the shell you use which might help #26.

antidot could generate something like this:

# begin antidot
...
# end antidot

When antidot clean is ran it'd modify this section leaving everything else in the file untouched.

Or should we duplicate it?

I think they'd need to be duplicated because not everyone uses pam_env. One idea could be to only write to ~/.pam_environment if the file already exists.

aidanharris avatar Dec 04 '20 21:12 aidanharris

This feels like asking for another supported 'shell'. While autodetecting zsh/bash/sh would be nice, I think just looking for a .pam_environment file might not be what the user wants. Since the default is running interactive, maybe asking the user for a supported output format would be neat, if some env var or arg isn't passed in.


@aidanharris I have setup a custom ZDOTDIR in my .profile, which executes once during login. Is this any different than setting ZDOTDIR in .pam_environment?


Somewhat related, lemme know if I should just remove this section of the comment:

I have written a zsh package manager that operates similar to antidot, but instead of writing files it only writes to stdout.

So, instead of antidot init having those two source $HOME/.local/share/antidot/{alias,env}.sh lines, it just embeds their contents.

So how does zr --update work then? I set a variable _ZR=$0 (would be something like ${h:0} in bash i think). This lets the user write the file anywhere when redirecting from stdout, but also informs the tool what files to parse when updating.

jedahan avatar Dec 09 '20 20:12 jedahan

I just added support for shells other than bash. It is released in version v0.5.0. Adding another shell is easier now although I think what you (@aidanharris) ask for is different.

Today I read the env file and add a var to it on every export action. I thought about updating a JSON file and generating the formats from it but I guess I just didn't go that path. It will however ease adding this feature if I understand it correctly.

doron-cohen avatar Jan 18 '21 09:01 doron-cohen