X-Git-Url: https://git.sev.monster/~sev/dotfiles.git/blobdiff_plain/8d4a98e19ec40334ed8e8f2ce4e5a9f094bdbcaf..ea963a9040124c7535e11af2731195cd04bb653d:/etc/zsh/.zprofile?ds=sidebyside diff --git a/etc/zsh/.zprofile b/etc/zsh/.zprofile index 777e0fa..3bad054 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 @@ -115,7 +110,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 +120,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 +206,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 ]] && @@ -431,5 +430,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