# add as many generic paths as possible to keep the order we want
# NOTE: /usr/{local,pkg,games} are unix/bsdisms
syspath=("$path[@]")
- path=({~/,/,/usr/}sbin /opt/{s,}bin /usr/local/{s,}bin /usr/pkg/{s,}bin
- /usr/X11R{7,6}/bin /usr/games {~/,/,/usr/}bin)
+ path=({~,~/.local,,/usr,/opt,/usr/local,/usr/pkg}/sbin
+ {~,~/.local,,/usr,/opt,/usr/local,/usr/pkg}/bin
+ /usr/X11R{7,6}/bin /usr/games)
((len=$#path))
path=("$path[@]" "$syspath[@]")
# remove nonexistent and duplicate paths
# NOTE: include and then remove CONFIG_HOME and DATA_HOME to ensure they
# are not present in the array if it was added before we got to it
typeset -UT XDG_CONFIG_DIRS xdg_config_dirs
- typeset -UT XDG_DATA_DIRS xdg_data_dirs
- export XDG_CONFIG_HOME=$HOME/etc
- xdg_config_dirs=($XDG_CONFIG_HOME $HOME/.config
+ export XDG_CONFIG_HOME=~/etc
+ mkdir -p $XDG_CONFIG_HOME
+ xdg_config_dirs=($XDG_CONFIG_HOME ~/.config
{/opt,/usr/local,/usr/pkg,}/etc/xdg
"${XDG_CONFIG_DIRS:+${xdg_config_dirs[@]}}")
export XDG_CONFIG_DIRS=${XDG_CONFIG_DIRS#$XDG_CONFIG_HOME}
- export XDG_DATA_HOME=$HOME/share
- xdg_data_dirs=($XDG_DATA_HOME $HOME/.local/share
+
+ typeset -UT XDG_DATA_DIRS xdg_data_dirs
+ export XDG_DATA_HOME=~/share
+ mkdir -p $XDG_DATA_HOME
+ xdg_data_dirs=($XDG_DATA_HOME ~/.local/share
/{opt,usr/local,usr/pkg,usr}/share
"${XDG_DATA_DIRS:+${xdg_data_dirs[@]}}")
export XDG_DATA_DIRS=${XDG_DATA_DIRS#$XDG_DATA_HOME}
+
+ export XDG_STATE_HOME=~/var/lib
+ mkdir -p $XDG_STATE_HOME
+
# use our custom tmp for cache and runtime
export XDG_CACHE_HOME=$_sev_tmp/.xdg.cache
export XDG_RUNTIME_DIR=$_sev_tmp/.xdg.runtime
elif [[ -e $x ]]; then
rm -rf $x 2>/dev/null
fi
+ # XXX: cache does not have to be 700 according to spec
mkdir -m700 $x 2>/dev/null
done
+
# source user dirs after other vars
[[ -e $XDG_CONFIG_HOME/user-dirs.dirs ]] &&
emulate sh -c "source $XDG_CONFIG_HOME/user-dirs.dirs"
# would open up too many edge cases where it wouldn't work or be clunky
# (e.g. asking for password twice) to make it worth it.
if [[ ! -v _sev_setup_agents ]] {
+ export GNUPGHOME=~/etc/gnupg
+
function _socketpath {
# dirs are percent-encoded: https://stackoverflow.com/a/64312099
echo ${1//(#b)%([[:xdigit:]](#c2))/${(#):-0x$match[1]}}