config: Cleanup and fix bugs

This commit is contained in:
Dylan Araps 2018-06-04 09:58:27 +10:00
parent 02c7c90496
commit c652bfb97b
1 changed files with 13 additions and 16 deletions

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() {
@ -4656,7 +4653,7 @@ get_distro_ascii() {
# This function gets the distro ascii art and colors. # This function gets the distro ascii art and colors.
# #
# $ascii_distro is the same as $distro. # $ascii_distro is the same as $distro.
case "$( trim "$ascii_distro")" in case "$(trim "$ascii_distro")" in
"AIX"*) "AIX"*)
set_colors 2 7 set_colors 2 7
read -rd '' ascii_data <<'EOF' read -rd '' ascii_data <<'EOF'