我不知道如何访问不仅在定义的变量~/.config/user-dirs.dirs
有xdg-user-dir
,例如"$(xdg-user-dir VIDEOS)"
,而且下面的标准变量:
XDG_CACHE_HOME:-$HOME/.cache
XDG_CONFIG_HOME:-$HOME/.config
XDG_DATA_HOME:-$HOME/.local/share
XDG_RUNTIME_DIR:-"/run/user/$USER"
XDG_CONFIG_DIRS:-/etc/xdg
XDG_DATA_DIRS:-/usr/local/share:/usr/share
为此,我在~/.bash_login
文件中执行以下操作:
# Define standard directories.
declare -gx XDG_CACHE_HOME=~/.cache
declare -gx XDG_CONFIG_HOME=~/.config
declare -gx XDG_DATA_HOME=~/.local/share
declare -gx XDG_RUNTIME_DIR="/run/user/$USER"
declare -gx XDG_CONFIG_DIRS="$(IFS=: path /etc/xdg)"
declare -gx XDG_DATA_DIRS="$(IFS=: path /usr/local/share:/usr/share)"
# Source supplementary directories to export or overwrite existing standard ones.
declare a="$XDG_CONFIG_HOME/user-dirs.dirs"
if [[ -e $a ]]; then
source "$a"
declare b=""
for b in ${!XDG_*}; do
if [[ $b =~ ^XDG_[_[:alnum:]]+_DIR$ ]]; then
declare -gx "$b"
fi
done
fi
除了“ XDG”目录结构规范定义的用户目录变量以外,是否有访问上述目录和路径变量的机制?
XDG_RUNTIME_DIR:-"/run/user/$UID"