From 6637e750c92256c3141f8197a20a182a247cfbeb Mon Sep 17 00:00:00 2001 From: Salt Date: Sun, 10 Feb 2019 12:20:05 -0600 Subject: [PATCH] tmp: Use XDG spec for Templates dir --- tmp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tmp b/tmp index 1666ac5..bffded1 100755 --- a/tmp +++ b/tmp @@ -52,13 +52,20 @@ done # Copy in template directory if [ -n "$1" ]; then - copydir="$HOME/Templates/tmp/$1" + # Source in XDG dirs, if they exist + userdirs="${XDG_CONFIG_HOME:-~/.config}/user-dirs.dirs" + if [ -f "$userdirs" ]; then + source "$userdirs" + fi + unset userdirs + copydir="${XDG_TEMPLATES_DIR:-~/Templates}/tmp/$1" if [ -d "$copydir" ]; then log "Using template \"$1\"" cp -r "$copydir"/* "$tmpdir" else log "Could not find template directory \"$copydir\"" fi + unset copydir fi trap "cleanup" EXIT