While poking through the linux kernel source code, I found a hidden way to fade in and out on a pure linux console.
1// fade.h 2 3/* Routines to fade the first 16 palette colors to and from black, 4 using the Linux console routines. (See drivers/char/console.c, look 5 for ESpalette) */ 6 7/* the default colour table, for VGA+ colour systems */ 8int default_red[] = {0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x55,0xff,0x55,0xff,0x55,0xff,0x55,0xff}; 9int default_grn[] = {0x00,0x00,0xaa,0x55,0x00,0x00,0xaa,0xaa,0x55,0x55,0xff,0xff,0x55,0x55,0xff,0xff}; 10int default_blu[] = {0x00,0x00,0x00,0x00,0xaa,0xaa,0xaa,0xaa,0x55,0x55,0x55,0x55,0xff,0xff,0xff,0xff}; 11 12unsigned int steps=64; /* How many steps to fade in. Can be decreased for 13 less smooth but quicker fading. */ 14 15/* Requires two args. One is boolean (true for fade in, false for fade out), 16 second is fading time in ms. A third, if provided, will be used as nubmer 17 of steps.*/ 18 19int fadetime = 0; 20int FDE=1; 21 22int fadein() 23{ 24if (FDE == 1) { 25 unsigned long restsize; 26 unsigned int i; 27 unsigned char j, stepsize, red, green, blue; 28 29 stepsize=256/steps; 30 restsize=1000 * fadetime/steps; 31 for (i=0; i<=255; i+=stepsize) { 32 printf("\e[A"); 33 fflush(stdout); 34 for (j=0; j<=15; j++) { 35 red=default_red[j]*i/256; 36 green=default_grn[j]*i/256; 37 blue=default_blu[j]*i/256; 38 printf("\e]P%1X%02X%02X%02X",j,\ 39 red, green, blue); 40 } 41 usleep(restsize); 42 } 43 printf("\e]R"); 44} 45} 46 47int fadeout() 48{ 49if (FDE == 1) { 50 unsigned long restsize; 51 int i; 52 unsigned char j, stepsize, red, green, blue; 53 54 steps=64; 55 stepsize=256/steps; 56 restsize=1000 * fadetime/steps; 57 for (i=256; i>=0; i-=stepsize) { 58 printf("\e[A"); 59 fflush(stdout); 60 for (j=0; j<=15; j++) { 61 red=default_red[j]*i/256; 62 green=default_grn[j]*i/256; 63 blue=default_blu[j]*i/256; 64 printf("\e]P%1X%02X%02X%02X",j,\ 65 red, green, blue); 66 } 67 usleep(restsize); 68 } 69} 70} 71 72// fadein.c 73 74/* Routines to fade the first 16 palette colors to and from black, 75 using the Linux console routines. (See drivers/char/console.c, look 76 for ESpalette) */ 77 78#include <stdio.h> /* do we need this anymore? */ 79#include <unistd.h> /* ioperm */ 80 81/* the default colour table, for VGA+ colour systems */ 82int default_red[] = {0x00,0xaa,0x00,0xaa,0x00,0xaa,0x00,0xaa,0x55,0xff,0x55,0xff,0x55,0xff,0x55,0xff}; 83int default_grn[] = {0x00,0x00,0xaa,0x55,0x00,0x00,0xaa,0xaa,0x55,0x55,0xff,0xff,0x55,0x55,0xff,0xff}; 84int default_blu[] = {0x00,0x00,0x00,0x00,0xaa,0xaa,0xaa,0xaa,0x55,0x55,0x55,0x55,0xff,0xff,0xff,0xff}; 85 86unsigned int steps=64; /* How many steps to fade in. Can be decreased for 87 less smooth but quicker fading. */ 88 89/* Requires two args. One is boolean (true for fade in, false for fade out), 90 second is fading time in ms. A third, if provided, will be used as nubmer 91 of steps.*/ 92 93int main(int argc, char *argv[]) 94{ 95 if (argc > 3) { steps=atoi(argv[3]); } 96 return ( atoi(argv[1]) ? fadein(atoi(argv[2])) : fadeout(atoi(argv[2])) ); 97} 98 99int fadein(int fadetime)100{101 unsigned long restsize;102 unsigned int i;103 unsigned char j, stepsize, red, green, blue;104105 stepsize=256/steps;106 restsize=1000 * fadetime/steps;107 for (i=0; i<=255; i+=stepsize) {108 printf("\e[A\n"); /* Because we get no output w/o newlines */109 for (j=1; j<=15; j++) {110 red=default_red[j]*i/256;111 green=default_grn[j]*i/256;112 blue=default_blu[j]*i/256;113 /* printf("P%1XR%dG%dB%d\t", j, red, green, blue); */114 printf("\e]P%1X%02X%02X%02X",j,\115 red, green, blue);116 }117 usleep(restsize);118 }119 printf("\e]R");120}121122int fadeout(int fadetime)123{124 unsigned long restsize;125 int i;126 unsigned char j, stepsize, red, green, blue;127128 steps=64;129 stepsize=256/steps;130 restsize=1000 * fadetime/steps;131 for (i=256; i>=0; i-=stepsize) {132 printf("\e[A\n"); /* Because we get no output w/o newlines */133 for (j=1; j<=15; j++) {134 red=default_red[j]*i/256;135 green=default_grn[j]*i/256;136 blue=default_blu[j]*i/256;137 /* printf("P%1XR%dG%dB%d\t", j, red, green, blue); */138 printf("\e]P%1X%02X%02X%02X",j,\139 red, green, blue);140 }141 usleep(restsize);142 }143}144145// fademe.c146147#include <stdio.h>148#include "fade.h"149150void main()151{152 fadeout();153 fadein();154}