Tektronix Popups.

Tavis Ormandy

$Id: a07cf90837a3c4373b82d6724b97593810766af7 $

Intro

xterm can emulate a Tektronix 4010 terminal, It’s actually pretty neat, it’s enabled by default and applications can plot simple graphics (lines, curves, etc) or use it to show graphs.

XTerm Popup Ad

It randomly occurred to me that windows unexpectedly opening is a bit like a popup browser ad.

Well, it turns out that Tektronix emulation in xterm is so fast that you can draw monochrome bitmaps. Nobody ever asked for or wanted this, but here is a README file that abuses this to create a popup ad when you cat it in an xterm. 😈

Recipe

Here is how I made this:

GIMP popup-ad
GIMP popup-ad
$ convert -flip -colors 2 xterm-popup.png rgb:xterm-popup-400x200.rgb
#include <stdio.h>
#include <stdlib.h>

// Convert RGB into monochrome points for gnuplot
// Usage: ./genplot <width> <height> < image.rgb > plot.dat
// -- taviso@gmail.com December, 2020

int main(int argc, char **argv)
{
    int r, g, b;
    int x, y;
    int width  = atoi(argv[1]);
    int height = atoi(argv[2]);

    for (x = y = 0;; x++) {

        x %= width;
        y += !x;

        r = getchar();
        g = getchar();
        b = getchar();

        if (feof(stdin))
            break;

        if (!!r || !!g || !!b)
            continue;

        printf("%u %u\n", x, y - 1);
    }
    return 0;
}

Now gnuplot can parse that file and generate Tetronix commands that you can just append to a text file. I needed to experiment with the pt and ps options to find the best look, but it worked out pretty well. You’re welcome!

$ gnuplot -e "set terminal xterm;
>  unset key; unset ytics; unset xtics;
>  plot 'plot.dat' pt 2 ps 1" >> README.txt

Don’t worry, if this is ever abused, you can always do alias ucat-origin="cat -v" 😂