diff --git a/config/zsh/.zlogout b/config/zsh/.zlogout new file mode 120000 index 0000000..4a52f7a --- /dev/null +++ b/config/zsh/.zlogout @@ -0,0 +1 @@ +zlogout \ No newline at end of file diff --git a/config/zsh/logout/xdg-clear b/config/zsh/logout/xdg-clear new file mode 100644 index 0000000..414c96e --- /dev/null +++ b/config/zsh/logout/xdg-clear @@ -0,0 +1,2 @@ +#! zsh +(( $(w -h $LOGNAME | wc -l) == 1 )) && rm -rf $XDG_RUNTIME_DIR diff --git a/config/zsh/zlogout b/config/zsh/zlogout new file mode 100644 index 0000000..f4b368a --- /dev/null +++ b/config/zsh/zlogout @@ -0,0 +1,2 @@ +#! zsh +for f in $ZDOTDIR/logout/*(N); source $f diff --git a/zshenv b/zshenv index 8d54939..83b0cbc 100644 --- a/zshenv +++ b/zshenv @@ -3,12 +3,17 @@ : ${XDG_CONFIG_HOME:=~/.config} : ${XDG_DATA_HOME:=~/.local/share} -# For XDG_RUNTIME_DIR, pick a temporary directory - officially it should be -# destroyed when the user logs out but close enough. The reason for suffixing -# /xdg-$USER is that TMPDIR does not necessarily belong to the current user -# exclusively (although it does under MacOS and PAM). -[[ -z $XDG_RUNTIME_DIR ]] && XDG_RUNTIME_DIR=${${TMPDIR-/tmp}%/}/xdg-$LOGNAME -[[ -d $XDG_RUNTIME_DIR ]] || mkdir -p $XDG_RUNTIME_DIR +# For XDG_RUNTIME_DIR, pick a temporary directory - the spec actually +# *requires* that it's destroyed when the user logs out, so that's handled by a +# file in zlogout. The reason for suffixing /xdg-$UID is that TMPDIR does not +# necessarily belong to the current user exclusively (although it does under +# MacOS and PAM). This is especially true if $TMPDIR isn't set at all and /tmp +# is used! +[[ -z $XDG_RUNTIME_DIR ]] && XDG_RUNTIME_DIR=${${TMPDIR-/tmp}%/}/xdg-$UID +if ! [[ -d $XDG_RUNTIME_DIR ]]; then + mkdir -p $XDG_RUNTIME_DIR + chmod 0700 $XDG_RUNTIME_DIR +fi export XDG_CONFIG_HOME XDG_CACHE_HOME XDG_DATA_HOME XDG_RUNTIME_DIR # The real zsh config lives in XDG_CONFIG_HOME! ;)