From b119a154b08b246426363f9be555917fb4a41063 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 4 Jun 2018 08:33:24 +1000 Subject: [PATCH] term_font: cleanup --- neofetch | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/neofetch b/neofetch index 23182103..9d436cde 100755 --- a/neofetch +++ b/neofetch @@ -2758,18 +2758,13 @@ get_term_font() { case "$term" in "alacritty"*) - if [[ -f "${XDG_CONFIG_HOME}/alacritty.yml" ]]; then - alacritty_file="${XDG_CONFIG_HOME}/alacritty.yml" + shopt -s nullglob + confs=({$XDG_CONFIG_HOME,$HOME}/{alacritty,}/{.,}alacritty.ym?) + shopt -u nullglob - elif [[ -f "${XDG_CONFIG_HOME}/alacritty/alacritty.yml" ]]; then - alacritty_file="${XDG_CONFIG_HOME}/alacritty/alacritty.yml" + [[ -f "${confs[0]}" ]] || return - elif [[ -f "${HOME}/.alacritty.yml" ]]; then - alacritty_file="${HOME}/.alacritty.yml" - fi - - term_font="$(awk -F ':|#' '/normal:/ {getline; print}' \ - "$alacritty_file")" + term_font="$(awk -F ':|#' '/normal:/ {getline; print}' "${confs[0]}")" term_font="${term_font/*family:}" term_font="${term_font/$'\n'*}" term_font="${term_font/\#*}" @@ -2846,19 +2841,11 @@ END ;; "kitty"*) - if [[ -f "${KITTY_CONFIG_DIRECTORY}/kitty/kitty.conf" ]]; then - kitty_file="${KITTY_CONFIG_DIRECTORY}/kitty/kitty.conf" + shopt -s nullglob + confs=({$KITTY_CONFIG_DIRECTORY,$XDG_CONFIG_HOME,~/Library/Preferences}/kitty/kitty.con?) + shopt -u nullglob - elif [[ -f "${XDG_CONFIG_HOME}/kitty/kitty.conf" ]]; then - kitty_file="${XDG_CONFIG_HOME}/kitty/kitty.conf" - - elif [[ -f "${HOME}/.config/kitty/kitty.conf" ]]; then - kitty_file="${HOME}/.config/kitty/kitty.conf" - - elif [[ -f "${HOME}/Library/Preferences/kitty/kitty.conf" ]]; then - kitty_file="${HOME}/Library/Preferences/kitty/kitty.conf" - - fi + [[ -f "${confs[0]}" ]] || return term_font="$(awk '/^([[:space:]]*|[^#_])font_family[[:space:]]+/ { $1 = ""; @@ -2868,7 +2855,7 @@ END /^([[:space:]]*|[^#_])font_size[[:space:]]+/ { size = $2 } - END { print font " " size}' "${kitty_file}")" + END { print font " " size}' "${confs[0]}")" ;; "konsole"*)