From 31578af72b5bc3d609e5584dd7d1972aead6be9c Mon Sep 17 00:00:00 2001 From: AtifChy Date: Tue, 17 Aug 2021 13:43:05 +0600 Subject: [PATCH] st xresource patch support --- neofetch | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/neofetch b/neofetch index 9fd88247..46160d48 100755 --- a/neofetch +++ b/neofetch @@ -3544,16 +3544,25 @@ END # like a font definition. NOTE: There is a slight limitation in this approach. # Technically "Font Name" is a valid font. As it doesn't specify any font options # though it is hard to match it correctly amongst the rest of the noise. - [[ -n "$binary" ]] && - term_font=$( - strings "$binary" | + st_bin=$(strings "$binary") - grep -m 1 "*font[^2]" - ) + # Grab font information from strings in binary. + term_font=${term_font:-"$( + grep -F -m 1 \ + -e "pixelsize=" \ + -e "size=" \ + -e "antialias=" \ + -e "autohint=" <<< "$st_bin" + )"} + + # Grab font information from Xresources. + [[ $st_bin == *resource* ]] && { + term_font=$(xrdb -query | grep -im 1 -e "^${term/d}"'\**\.*font:' -e '^\*font:' -e '^\*.font:') + term_font=$(trim "${term_font/*[\*.]"font:"}") + } fi term_font="${term_font/xft:}" - term_font="${term_font#*=}" term_font="${term_font/:*}" ;;