From 90c46651d6d3b04ce6dca524f0e34561edcc0e7f Mon Sep 17 00:00:00 2001 From: Vincent Aranega Date: Thu, 16 Jun 2016 12:14:05 +0200 Subject: [PATCH 1/3] Add terminal font detection support for terminology Support for terminology font name detection is based on the terminology config file. This file is always located here: `~/.config/terminology/config/standard/base.cfg` (https://github.com/billiob/terminology/blob/30cb65625bfa3b9030b80308d76ec2f30b62bd02/src/bin/config.c#L216) and is in a data/binary format. The only way I found (beside coding a dedicated extractor) is to use `strings`. The font name seems to be placed right before the `font.name` string. strings ~/.config/terminology/config/standard/base.cfg | grep -B1 font.name | head -1 Here are results that could be output: $ strings ~/.config/terminology/config/standard/base.cfg | grep -B1 font.name | head -1 6x13.pcf --> (for a bitmap font) and with another font selected $ strings ~/.config/terminology/config/standard/base.cfg | grep -B1 font.name | head -1 Inconsolata:style=Regular These results are easily "parseable" in order to extract the font name for display. --- neofetch | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/neofetch b/neofetch index c4c42036..84eb1970 100755 --- a/neofetch +++ b/neofetch @@ -1814,6 +1814,12 @@ gettermfont () { "Apple_Terminal") termfont="$(osascript -e 'tell application "Terminal" to font name of window frontmost')" ;; + + "terminology") + termfont="$(strings ${XDG_CONFIG_HOME}/terminology/config/standard/base.cfg | grep -B1 font.name | head -1)" + termfont="${termfont/.pcf}" + termfont="${termfont/:*}" + ;; esac } From f5a9393d4bacb2767e810dfd812bbac24567e2b0 Mon Sep 17 00:00:00 2001 From: Vincent Aranega Date: Thu, 16 Jun 2016 15:39:30 +0200 Subject: [PATCH 2/3] Enhanced font detection for terminology As 'grep -B' is a GNU extension, a more portable solution is preferable. The most direct and simple solution would be using 'awk': awk '/^font.name$/{print a}{a=$0}' But a sed solution could also be applied: sed -n '/^font\.name$/{g;1!p;};h' --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 84eb1970..83207c5c 100755 --- a/neofetch +++ b/neofetch @@ -1816,7 +1816,7 @@ gettermfont () { ;; "terminology") - termfont="$(strings ${XDG_CONFIG_HOME}/terminology/config/standard/base.cfg | grep -B1 font.name | head -1)" + termfont="$(strings ${XDG_CONFIG_HOME}/terminology/config/standard/base.cfg | awk '/^font.name$/{print a}{a=$0}')" termfont="${termfont/.pcf}" termfont="${termfont/:*}" ;; From e2b14b26adf1ca77346896d51fd8b401201d6f12 Mon Sep 17 00:00:00 2001 From: Vincent Aranega Date: Thu, 16 Jun 2016 16:11:00 +0200 Subject: [PATCH 3/3] Fix potential errors from a missing escaped char in regex --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 83207c5c..60fde897 100755 --- a/neofetch +++ b/neofetch @@ -1816,7 +1816,7 @@ gettermfont () { ;; "terminology") - termfont="$(strings ${XDG_CONFIG_HOME}/terminology/config/standard/base.cfg | awk '/^font.name$/{print a}{a=$0}')" + termfont="$(strings ${XDG_CONFIG_HOME}/terminology/config/standard/base.cfg | awk '/^font\.name$/{print a}{a=$0}')" termfont="${termfont/.pcf}" termfont="${termfont/:*}" ;;