From 2d429138e2e24770af77c7b8370df48601cd50c8 Mon Sep 17 00:00:00 2001 From: anki-code Date: Mon, 30 Mar 2020 22:24:55 +0300 Subject: [PATCH] XDG --- entrypoint.sh | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index cb55370..7e2a63f 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -11,10 +11,11 @@ # -v Verbose mode: 1 - verbose, 2 - super verbose # -e -e ... Environement variables (B64 is base64 encoded string) # -b -b ... Base64 encoded bash command -# -H Home path. Will be $HOME on the host. +# -H HOME path. Will be $HOME on the host. +# -X XDG_* path (https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) # -while getopts f:c:C:v:e:b:H: option +while getopts f:c:C:v:e:b:H:X: option do case "${option}" in @@ -25,6 +26,7 @@ v) VERBOSE=${OPTARG};; e) ENV+=("$OPTARG");; b) EBASH+=("$OPTARG");; H) HOMEPATH=${OPTARG};; +X) XDGPATH=${OPTARG};; esac done @@ -108,9 +110,20 @@ else export HOME=$XXH_HOME fi -export XDG_CONFIG_HOME=$HOME/.config -export XDG_DATA_HOME=$HOME/.local/share +if [[ $XDGPATH != '' ]]; then + xdgrealpath=`readlink -f $XDGPATH` + if [[ ! -d $xdgrealpath ]]; then + echo "XDG path not found: $xdgrealpath" + echo "Set XDG path to $XXH_HOME" + export XDGPATH=$XXH_HOME + fi +else + export XDGPATH=$XXH_HOME +fi +export XDG_CONFIG_HOME=$XDGPATH/.config +export XDG_DATA_HOME=$XDGPATH/.local/share +export XDG_CACHE_HOME=$XDGPATH/.cache # # Run the portable shell