home/.config/dtfscripts/common.sh

30 lines
807 B
Bash
Executable File

#!/usr/bin/env bash
# Copyright 2018 rehashedsalt
# Licensed to all under the terms of the MIT License
function dtf_log() {
name="$(basename $0 .sh)"
if [ -z ${1+x} ]; then return 1; fi
printf "$name: $1\n"
}
## Patch some directories
if [[ "$PATH" != *"$HOME/.local/bin"* ]]; then
dtf_log "Patching path for $HOME/.local/bin"
export PATH="$HOME/.local/bin:$PATH"
fi
if [[ "$XDG_CONFIG_HOME" == "" ]]; then
dtf_log "Correcting configuration directory"
export XDG_CONFIG_HOME="$HOME/.config"
fi
if [[ "$XDG_RUNTIME_DIR" == "" ]]; then
dtf_log "Correcting runtime directory"
export XDG_RUNTIME_DIR="/run/user/$UID"
fi
## Set some more variables
export DTF_CONFIG_HOME="$XDG_CONFIG_HOME/dtfscripts"
export DTF_SERVICES_DIR="$DTF_CONFIG_HOME/services"
export DTF_TASKS_DIR="$DTF_CONFIG_HOME/tasks"