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` (30cb65625b/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.
This commit is contained in:
Vincent Aranega 2016-06-16 12:14:05 +02:00
parent 09e3dc5146
commit 90c46651d6

View file

@ -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
}