antidot
antidot copied to clipboard
Option to use ~/.pam_environment
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
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?
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.
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.
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.