From de09819ff538434d3c6bd58f00b87f83e27c10c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Eric=20Janouch?= Date: Sat, 12 Sep 2020 10:50:28 +0200 Subject: [PATCH] Add w3mimgdisplay checking --- termtest.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/termtest.c b/termtest.c index efe8aed..e7335c1 100644 --- a/termtest.c +++ b/termtest.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -257,19 +258,23 @@ int main(int argc, char *argv[]) { const char *windowid = getenv("WINDOWID"); if (windowid) { printf("WINDOWID=%s\n", windowid); + printf("There should be a picture. Press a key.\n"); + poll(NULL, 0, 50 /* wait for a refresh */); char buf[1000] = ""; snprintf(buf, sizeof buf, "/usr/lib/w3m:%s", getenv("PATH")); setenv("PATH", buf, true /* replace */); - // TODO: - // - run w3mimgdisplay now, hardcoded visual check - // - I guess I'll need a picture to show - // - /usr/share/pixmaps/debian-logo.png - // - /usr/share/icons/HighContrast/48x48/stock/gtk-yes.png - // - we get run from a relative path, so not sure about local - // - or we can create our own picture, something easily compressible - // - can even pass that as an fd during fork and use /dev/fd/N + glob_t gb; + glob("/usr/share/pixmaps/*.xpm", 0, NULL, &gb); + glob("/usr/share/pixmaps/*.png", GLOB_APPEND, NULL, &gb); + + FILE *fp = popen("w3mimgdisplay >/dev/null", "w"); + fprintf(fp, "0;1;0;0;%d;%d;;;;;%s\n4;\n3;", 100, 100, gb.gl_pathv[0]); + pclose(fp); + globfree(&gb); + + comm("", true); } printf("-- Sixel graphics\n");