Detecting "New" Chafa

This commit is contained in:
Ben Winston - ben at benwinston.us 2022-12-08 20:29:10 -05:00 committed by Lionel Dricot
parent 7d57fd9919
commit 8875a0068c
1 changed files with 8 additions and 3 deletions

View File

@ -105,9 +105,14 @@ if _HAS_CHAFA:
# starting with 1.10, chafa can return only one frame
# which allows us to drop dependancy for PIL
output = run("chafa --version")
# with chafa < 1.10, --version was returned to stderr instead of stdout.
if output != '':
_NEW_CHAFA = True
# output is "Chafa version M.m.p"
# check for m < 1.10
try:
chafa_major, chafa_minor, _ = output.split("\n")[0].split(" ")[-1].split(".")
if int(chafa_major) >= 1 and int(chafa_minor) >= 10:
_NEW_CHAFA = True
except:
pass
if _NEW_CHAFA :
_RENDER_IMAGE = True
if _HAS_TIMG :