From f06071e7c74c06566ac2be99fec5c5ff65923b4c Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Wed, 22 Sep 2021 10:22:09 +1000 Subject: [PATCH] Drop fragile XDG_RUNTIME_DIR support An XDG runtime directory cannot be provided reliably by the shell, because it's supposed to have the same lifetime as the user's login session, and the shell doesn't have a reliable way to keep track of that lifetime. There are probably nonportable ways to get a conforming directory, such as making a request to PAM, but PAM is supposed to set XDG_RUNTIME_DIR itself anyway and also doesn't exist on Macs, which I use most of the time. My configuration isn't actually using XDG_RUNTIME_DIR anyway, so I don't want to provide the misleading impression that a runtime directory with proper behaviour conforming to the specification is definitely available. --- config/zsh/logout/xdg-clear | 2 -- zshenv | 13 +------------ 2 files changed, 1 insertion(+), 14 deletions(-) delete mode 100644 config/zsh/logout/xdg-clear diff --git a/config/zsh/logout/xdg-clear b/config/zsh/logout/xdg-clear deleted file mode 100644 index 534de2c..0000000 --- a/config/zsh/logout/xdg-clear +++ /dev/null @@ -1,2 +0,0 @@ -#! zsh -(( $SHLVL == 1 && $(w -h $LOGNAME | wc -l) == 1 )) && rm -rf $XDG_RUNTIME_DIR 2>/dev/null diff --git a/zshenv b/zshenv index b8f836d..a156484 100644 --- a/zshenv +++ b/zshenv @@ -4,18 +4,7 @@ : ${XDG_DATA_HOME:=~/.local/share} : ${XDG_STATE_HOME:=~/.local/state} -# 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_STATE_HOME XDG_RUNTIME_DIR +export XDG_CONFIG_HOME XDG_CACHE_HOME XDG_DATA_HOME XDG_STATE_HOME # The real zsh config lives in XDG_CONFIG_HOME! ;) : ${ZDOTDIR:=$XDG_CONFIG_HOME/zsh}