From 8e367e41a457c425e083eea39484aa7f2277cc74 Mon Sep 17 00:00:00 2001 From: Bailey Kasin Date: Fri, 13 Oct 2023 20:14:29 -0700 Subject: [PATCH] Add support for alacritty's new config format Signed-off-by: Bailey Kasin --- neofetch | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/neofetch b/neofetch index dd3faa66..51c67290 100755 --- a/neofetch +++ b/neofetch @@ -4426,14 +4426,24 @@ get_term_font() { case $term in "alacritty"*) + # Alacritty switched to TOML for it's config the first version + # with that will take a long time to be in repos and gain adoption. + shopt -s nullglob - confs=({$XDG_CONFIG_HOME,$HOME}/{alacritty,}/{.,}alacritty.ym?) + confs_yaml=({$XDG_CONFIG_HOME,$HOME}/{alacritty,}/{.,}alacritty.ym?) + confs_toml=({$XDG_CONFIG_HOME,$HOME}/{alacritty,}/{.,}alacritty.tom?) shopt -u nullglob - [[ -f "${confs[0]}" ]] || return - - term_font="$(awk '/normal:/ {while (!/family:/ || /#/) - {if (!getline) {exit}} print; exit}' "${confs[0]}")" + if [[ -f "${confs_toml[0]}" ]]; then + term_font="$(awk '/normal:/ {while (!/family:/ || /#/) + {if (!getline) {exit}} print; exit}' "${confs_toml[0]}")" + elif [[ -f "${confs_yaml[0]}" ]]; then + term_font="$(awk -F' *= *' '/^\[.*\]$/{section=substr($0, 2, length-2)} + section == "font.normal" && $1 == "family"{sub(/^"/,"", $2); + sub(/"$/, "", $2); print $2}' "${confs_yaml[0]}")" + else + return + fi term_font="${term_font/*family:}" term_font="${term_font/$'\n'*}" term_font="${term_font/\#*}"