dylanaraps / neofetch

🖼️ A command-line system information tool written in bash 3.2+
MIT License
22.18k stars 1.66k forks source link

feature request `neofetch --config` returns the location of the config file #2457

Open iconoclasthero opened 7 months ago

iconoclasthero commented 7 months ago

Description

$ neofetch --config with no path specified (i.e., it should be called as $ neofetch --config /path/to/config.conf) should list the currently-used config file.

I think that occurs here and I could probably add it in a pull request...

get_user_config() {
    # --config /path/to/config.conf
    if [[ -f "$config_file" ]]; then
        source "$config_file"
        err "Config: Sourced user config. (${config_file})"
        return

    elif [[ -f "${XDG_CONFIG_HOME}/neofetch/config.conf" ]]; then
        source "${XDG_CONFIG_HOME}/neofetch/config.conf"
        err "Config: Sourced user config.    (${XDG_CONFIG_HOME}/neofetch/config.conf)"

    elif [[ -f "${XDG_CONFIG_HOME}/neofetch/config" ]]; then
        source "${XDG_CONFIG_HOME}/neofetch/config"
        err "Config: Sourced user config.    (${XDG_CONFIG_HOME}/neofetch/config)"

    elif [[ -z "$no_config" ]]; then
        config_file="${XDG_CONFIG_HOME}/neofetch/config.conf"

        # The config file doesn't exist, create it.
        mkdir -p "${XDG_CONFIG_HOME}/neofetch/"
        printf '%s\n' "$config" > "$config_file"
    fi
}

Neofetch version

7.1.0

Config file

That's what I'm looking for!

iconoclasthero commented 7 months ago
get_user_config() {
    # --config /path/to/config.conf
    if [[ -f "$config_file" ]]; then
        source "$config_file"
        err "Config: Sourced user config. (${config_file})"
        config_file_path="$config_file"
        return

    elif [[ -f "${XDG_CONFIG_HOME}/neofetch/config.conf" ]]; then
        source "${XDG_CONFIG_HOME}/neofetch/config.conf"
        err "Config: Sourced user config.    (${XDG_CONFIG_HOME}/neofetch/config.conf)"
        config_file_path="${XDG_CONFIG_HOME}/neofetch/config.conf"

    elif [[ -f "${XDG_CONFIG_HOME}/neofetch/config" ]]; then
        source "${XDG_CONFIG_HOME}/neofetch/config"
        err "Config: Sourced user config.    (${XDG_CONFIG_HOME}/neofetch/config)"
        config_file_path="${XDG_CONFIG_HOME}/neofetch/config"

    elif [[ -z "$no_config" ]]; then
        config_file="${XDG_CONFIG_HOME}/neofetch/config.conf"
        config_file_path="${XDG_CONFIG_HOME}/neofetch/config.conf"

        # The config file doesn't exist, create it.
        mkdir -p "${XDG_CONFIG_HOME}/neofetch/"
        printf '%s\n' "$config" > "$config_file"
    fi
}

and from the end of the case statement:

          # Other
            "--config")
                case $2 in
                    "none" | "off") ;;
                    "") get_user_config; printf '\nThe location of the config file is %s\n\n' "$config_f>
                    *)
                        config_file="$(get_full_path "$2")"
                        get_user_config
                    ;;
                esac
thomastubby commented 7 months ago

Per the "Getting Started" page, the default config path is $HOME/.config/neofetch/config.conf Using the --config flag does not result in a persistent change to the config path as it it must be specified each time when using neofetch.