Add w3mimgdisplay checking
This commit is contained in:
parent
7f7b725378
commit
de09819ff5
21
termtest.c
21
termtest.c
|
@ -27,6 +27,7 @@
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
#include <glob.h>
|
||||||
|
|
||||||
#include <curses.h>
|
#include <curses.h>
|
||||||
#include <term.h>
|
#include <term.h>
|
||||||
|
@ -257,19 +258,23 @@ int main(int argc, char *argv[]) {
|
||||||
const char *windowid = getenv("WINDOWID");
|
const char *windowid = getenv("WINDOWID");
|
||||||
if (windowid) {
|
if (windowid) {
|
||||||
printf("WINDOWID=%s\n", 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] = "";
|
char buf[1000] = "";
|
||||||
snprintf(buf, sizeof buf, "/usr/lib/w3m:%s", getenv("PATH"));
|
snprintf(buf, sizeof buf, "/usr/lib/w3m:%s", getenv("PATH"));
|
||||||
setenv("PATH", buf, true /* replace */);
|
setenv("PATH", buf, true /* replace */);
|
||||||
|
|
||||||
// TODO:
|
glob_t gb;
|
||||||
// - run w3mimgdisplay now, hardcoded visual check
|
glob("/usr/share/pixmaps/*.xpm", 0, NULL, &gb);
|
||||||
// - I guess I'll need a picture to show
|
glob("/usr/share/pixmaps/*.png", GLOB_APPEND, NULL, &gb);
|
||||||
// - /usr/share/pixmaps/debian-logo.png
|
|
||||||
// - /usr/share/icons/HighContrast/48x48/stock/gtk-yes.png
|
FILE *fp = popen("w3mimgdisplay >/dev/null", "w");
|
||||||
// - we get run from a relative path, so not sure about local
|
fprintf(fp, "0;1;0;0;%d;%d;;;;;%s\n4;\n3;", 100, 100, gb.gl_pathv[0]);
|
||||||
// - or we can create our own picture, something easily compressible
|
pclose(fp);
|
||||||
// - can even pass that as an fd during fork and use /dev/fd/N
|
globfree(&gb);
|
||||||
|
|
||||||
|
comm("", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("-- Sixel graphics\n");
|
printf("-- Sixel graphics\n");
|
||||||
|
|
Loading…
Reference in New Issue