termfont: Add URxvt support, Ignore commented lines in config files

This commit is contained in:
Dylan Araps 2016-05-17 00:30:11 +10:00
parent 2bf353eaab
commit abb110b57f
1 changed files with 16 additions and 5 deletions

View File

@ -1746,7 +1746,7 @@ getterm () {
name="$(ps -p $parent -o comm=)" name="$(ps -p $parent -o comm=)"
case "$name" in case "$name" in
"${SHELL/*\/}" | *"sh" | "tmux") getterm "$parent" ;; "${SHELL/*\/}" | *"sh" | "tmux" | "systemd") getterm "$parent" ;;
*) term="$name" ;; *) term="$name" ;;
esac esac
fi fi
@ -1761,22 +1761,33 @@ gettermfont () {
case "$term" in case "$term" in
"urxvt"*) "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") "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") "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") "terminator")
# This only works on a global basis right now. # This only works on a global basis right now.
# We need to figure out a way to get the current # We need to figure out a way to get the current
# profile in use. # 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 esac
} }