X-Git-Url: https://git.sev.monster/~sev/dotfiles.git/blobdiff_plain/8d4a98e19ec40334ed8e8f2ce4e5a9f094bdbcaf..c9ab0b12d4183935113856f0c9c5575c8e149208:/etc/zsh/.zprofile?ds=inline diff --git a/etc/zsh/.zprofile b/etc/zsh/.zprofile index 777e0fa..ec88809 100644 --- a/etc/zsh/.zprofile +++ b/etc/zsh/.zprofile @@ -11,12 +11,7 @@ # properly configured for any child processes. # * some desktop environments/graphical terminal emulators will start new # terminal windows with login shells, which runs .zprofile every time and -# leads to noticably slow startup times. -# * switching users without wiping the environment will result in paths and -# variables intended for the old user being used for the new user. while -# this may be considered an edge-case that should not be supported, there -# are legitimate reasons to want to do this, and in any case the shell -# should not choke or cause unexpected problems should it happen anyway. +# leads to noticably slow startup times if we have not already ran it. ### cleanup # XXX: only call after relevant vars have been set up, defined early so that @@ -84,9 +79,7 @@ if [[ ! -v _sev_setup_path || -o login ]] { # XXX: XDG specifies ~/.local/bin as the only user-writable dir for # executables, but we specify more; technically this is against spec syspath=("$path[@]") - path=(~/{.local/,}{s,}bin - {~/.local,{$PREFIX,}{,/opt,/usr{,/local,pkg}}}/sbin - {~/.local,{$PREFIX,}{,/opt,/usr{,/local,pkg}}}/bin + path=({{${_sev_home:-~},~}{/.local,},{$PREFIX,}{,/opt,/usr{,/local,/pkg}}}/{s,}bin /usr/{X11R{7,6}/bin,games}) ((len=$#path)) path=("$path[@]" "$syspath[@]") @@ -115,7 +108,7 @@ if [[ ! -v _sev_setup_path || -o login ]] { # XXX: perms are not specified for XDG dirs except runtime, but I think 760 # makes the most sense. shouldn't break anything since no one else should # be poking around in our dir. -[[ -e ~/.local ]] || mkdir -m760 ~/.local +[[ -e ${_sev_home:-~}/.local ]] || mkdir -m760 ${_sev_home:-~}/.local ### tmp # NOTE: specs say that POSIX tmp and XDG runtime directories should exist @@ -125,7 +118,7 @@ if [[ ! -v _sev_setup_path || -o login ]] { # toplevel session (i.e. SHLVL=1). this should placate most applications, # though it is not expressly spec compliant. if [[ ! -v _sev_tmp ]] { - _sev_tmp=~/.local/tmp + _sev_tmp=${_sev_home:-~}/.local/tmp # NOTE: race condition/remove in use files [[ -h $_sev_tmp ]] && unlink $_sev_tmp 2>/dev/null t=${TMPDIR:-${TEMP:-${TMP:-/tmp}}}/.home-$LOGNAME @@ -211,15 +204,19 @@ if [[ ! -v _sev_setup_xdg ]] { } } - # make runtime dir in our session-specific tmpdir - export XDG_RUNTIME_DIR=$TMPDIR/.xdg.runtime - # same as in tmpdir creation, ensure dir doesn't exist - if [[ -h $XDG_RUNTIME_DIR ]] { - unlink $XDG_RUNTIME_DIR 2>/dev/null - } elif [[ -e $XDG_RUNTIME_DIR ]] { - rm -rf $XDG_RUNTIME_DIR 2>/dev/null + if [[ -v XDG_RUNTIME_DIR ]] { + export XDG_RUNTIME_DIR + } else { + # make runtime dir in our session-specific tmpdir + export XDG_RUNTIME_DIR=$TMPDIR/.xdg.runtime + # same as in tmpdir creation, ensure dir doesn't exist + if [[ -h $XDG_RUNTIME_DIR ]] { + unlink $XDG_RUNTIME_DIR 2>/dev/null + } elif [[ -e $XDG_RUNTIME_DIR ]] { + rm -rf $XDG_RUNTIME_DIR 2>/dev/null + } + mkdir -m700 $XDG_RUNTIME_DIR 2>/dev/null } - mkdir -m700 $XDG_RUNTIME_DIR 2>/dev/null # source user dirs after other vars [[ -e $XDG_CONFIG_HOME/user-dirs.dirs ]] && @@ -347,8 +344,9 @@ if [[ -v commands[gpg-connect-agent] && ${+DISPLAY} + ${+WAYLAND_DISPLAY} == 0)) # XXX: don't know if gpg-agent supports comments after directives # XXX: path could have # + # XXX: we are assuming this is our pinentry from .local/bin sed -Ei 's#^([[:space:]]*pinentry-program[[:space:]]).*$#\1'${commands[pinentry]:-/dev/null}'#' \ - ${GNUPGHOME:-~/.gnupg}/gpg-agent.conf + ${GNUPGHOME:-~/.gnupg}/gpg-agent.conf 2>/dev/null # XXX: could check for changes before doing this to save perf gpg-connect-agent RELOADAGENT UPDATESTARTUPTTY /bye >/dev/null 2>&1 if {$p} { @@ -431,5 +429,3 @@ unfunction _gpg_socketpath ### load site-specific if [[ -f ${ZDOTDIR:-~}/.zprofile.local ]] { source ${ZDOTDIR:-~}/.zprofile.local } - -# vim: et sts=4 sw=4 ts=8 tw=79