From abb110b57f8c0fe898d90c9aa8727df7e1b8a8d1 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 17 May 2016 00:30:11 +1000 Subject: [PATCH] termfont: Add URxvt support, Ignore commented lines in config files --- neofetch | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/neofetch b/neofetch index be347e84..a6039e17 100755 --- a/neofetch +++ b/neofetch @@ -1746,7 +1746,7 @@ getterm () { name="$(ps -p $parent -o comm=)" case "$name" in - "${SHELL/*\/}" | *"sh" | "tmux") getterm "$parent" ;; + "${SHELL/*\/}" | *"sh" | "tmux" | "systemd") getterm "$parent" ;; *) term="$name" ;; esac fi @@ -1761,22 +1761,33 @@ gettermfont () { case "$term" in "urxvt"*) - # Need to figure out how to best parse the Xresources file. + termfont="$(awk -F ': ' '!/^($|!)/ && /\*font/ {printf $2}' "$HOME/.Xresources")" + + case "$termfont" in + "xft:"*) + termfont=${termfont/xft:} + termfont=${termfont/:*} + ;; + + "-"*) + termfont="$(awk -F '\\-' '{printf $3}' <<< "$termfont")" + ;; + esac ;; "xfce4-terminal") - termfont="$(awk -F '=' '/FontName/ {printf $2}' "${XDG_CONFIG_HOME}/xfce4/terminal/terminalrc")" + termfont="$(awk -F '=' '!/^($|\/\/)/ && /FontName/ {printf $2}' "${XDG_CONFIG_HOME}/xfce4/terminal/terminalrc")" ;; "termite") - termfont="$(awk -F '= ' '/font/ {printf $2; exit}' "${XDG_CONFIG_HOME}/termite/config")" + termfont="$(awk -F '= ' '!/^($|#)/ && /font/ {printf $2; exit}' "${XDG_CONFIG_HOME}/termite/config")" ;; "terminator") # This only works on a global basis right now. # We need to figure out a way to get the current # profile in use. - termfont="$(awk -F '= ' '/font/ {printf $2; exit}' "${XDG_CONFIG_HOME}/terminator/config")" + termfont="$(awk -F '= ' '!/^($|#)/ && /font/ {printf $2; exit}' "${XDG_CONFIG_HOME}/terminator/config")" ;; esac }