A better way to fix chafa and foot issue

This commit is contained in:
Nikita Ivanov 2022-11-23 23:01:23 +01:00
parent 1c7dc792cd
commit 08095635bc
No known key found for this signature in database
GPG Key ID: 6E656AC5B97B5133
5 changed files with 33 additions and 2 deletions

View File

@ -312,6 +312,30 @@ Print only text and do not use any image previewing method.
Do not print resolved path of symbolic links.
.
.TP
.B autochafa
By default,
.I Chafa
is always forced to use \(lqsymbols\(rq format because
.I lf
does not support
\(lqsixel\(rq output in the preview window.
However, one could install a
.UR https://github.com/horriblename/lf
fork of
.I lf
.UE
that does.
For such cases the
.B autochafa
option exists, which allows
.I Chafa
to decide which format to use.
Use it if you are sure that the version of
.I lf
you are using will be able to handle whatever output produced by
.IR Chafa .
.
.TP
.B showgpg
Preview
.BR gpg (1)

View File

@ -18,6 +18,10 @@ noimages() {
[ -n "$noimages" ]
}
autochafa() {
[ -z "$autochafa" ]
}
is_kitty() {
case "$TERM" in
*-kitty) return 0 ;;
@ -61,7 +65,8 @@ is_anim_image() {
}
chafa_run() {
chafa -s "${w}x${h}" -f symbols "$1"
autochafa && format='-f symbols' || format=
chafa -s "${w}x${h}" $format "$1" | sed 's/#/\n#/g'
}
setup_fifo() {

View File

@ -60,6 +60,7 @@ static struct Option options[] = {
DEF_OPTION_BOOL(forcechafa),
DEF_OPTION_BOOL(noimages),
DEF_OPTION_BOOL(nosymlinkinfo),
DEF_OPTION_BOOL(autochafa),
DEF_OPTION_BOOL(showgpg),
};

View File

@ -16,7 +16,7 @@ struct CTPV {
char *server_id_s;
struct {
int forcekitty, forcekittyanim, forcechafa, noimages, nosymlinkinfo;
int showgpg;
int autochafa, showgpg;
} opts;
};

View File

@ -42,6 +42,7 @@ RESULT run_script(char *script, size_t script_len, int *exitcode, int *signal,
OPT_SETENV(forcechafa);
OPT_SETENV(noimages);
OPT_SETENV(nosymlinkinfo);
OPT_SETENV(autochafa);
OPT_SETENV(showgpg);
char *scr = prepend_helpers(script, script_len);