config: Cleanup and fix bugs

This commit is contained in:
Dylan Araps 2018-06-04 09:58:27 +10:00
parent 02c7c90496
commit c652bfb97b

View file

@ -4015,7 +4015,7 @@ get_full_path() {
# For example "Pictures/Wallpapers" --> "/home/dylan/Pictures/Wallpapers" # For example "Pictures/Wallpapers" --> "/home/dylan/Pictures/Wallpapers"
# If the file exists in the current directory, stop here. # If the file exists in the current directory, stop here.
[[ -f "${PWD}/${1/*\/}" ]] && { printf '%s\n' "${PWD}/${1/*\/}"; return; } [[ -f "${PWD}/${1}" ]] && { printf '%s\n' "${PWD}/${1}"; return; }
! cd "${1%/*}" && { ! cd "${1%/*}" && {
err "Error: Directory '${1%/*}' doesn't exist or is inaccessible" err "Error: Directory '${1%/*}' doesn't exist or is inaccessible"
@ -4039,21 +4039,21 @@ get_full_path() {
} }
get_user_config() { get_user_config() {
# Check $config_file. mkdir -p "${XDG_CONFIG_HOME}/neofetch/"
[[ -f "$config_file" ]] && {
shopt -s nullglob
files=("$XDG_CONFIG_HOME"/neofetch/confi*)
shopt -u nullglob
# --config /path/to/config.conf
if [[ -f "$config_file" ]]; then
source "$config_file" source "$config_file"
err "Config: Sourced user config. (${config_file})" err "Config: Sourced user config. (${config_file})"
return return
}
mkdir -p "${XDG_CONFIG_HOME}/neofetch/"
# Check ${XDG_CONFIG_HOME}/neofetch and create the elif [[ -f "${files[0]}" ]]; then
# dir/files if they don't exist. source "${files[0]}"
if [[ -f "${XDG_CONFIG_HOME}/neofetch/config" ]]; then err "Config: Sourced user config. (${config_file})"
config_file="${XDG_CONFIG_HOME}/neofetch/config"
elif [[ -f "${XDG_CONFIG_HOME}/neofetch/config.conf" ]]; then
config_file="${XDG_CONFIG_HOME}/neofetch/config.conf"
else else
config_file="${XDG_CONFIG_HOME}/neofetch/config.conf" config_file="${XDG_CONFIG_HOME}/neofetch/config.conf"
@ -4061,9 +4061,6 @@ get_user_config() {
# The config file doesn't exist, create it. # The config file doesn't exist, create it.
printf '%s\n' "$config" > "$config_file" printf '%s\n' "$config" > "$config_file"
fi fi
source "$config_file"
err "Config: Sourced user config. (${config_file})"
} }
bar() { bar() {