Customizing the Linux framebuffer

Cursor

first off, and probably the most complicated to wrap your head around, the cursor.

^[[?X;Yc

X parameter

where X is the cursor shape; 0 is default, 1 is invisible, 2 is underline, ..., 4 is a half block, ..., 8 is a full block.

and add 16 if you want software cursor, add 32 if you want to always change the background, add 64 if you want to not have the same background and foreground.

Y parameter

where Y is the color attributes, where the byte is split into two nibbles, where the individual bits correspond to; high intensity or bright, red, green, and blue.

so if you want a red block cursor with default colors on hover (foreground);

0b01000000 == 64 == ^[[?24;64c

printf '\033[?24;64c'

since we didn't toggle the "bright" flag, that red probably looks a little dim, so try toggling it by using 0b11000000 instead.

Colors

as opposed to cursors, setting the 16-bit-palette is pretty straightforward.

the escape is ^[]PNRRGGBB

where P is a literal P.

where N is the hexadecimal representation of the index you want to set, 0 is 0, ..., 9 is 9, A is 10, B is 11, ... F is 15.

where RR, GG, and BB are hexadecimal representations of the red, green, and blue. (no doubt if you're reading this you know what a hex triplet/"html colors" are.)

so to set the default green to #00FF00;

printf '\033]P200FF00'

or to set the brightmagenta to #FF00FF;

printf '\033]PDFF00FF'

Default foreground and background

the background and foreground are limited in the way that they need to be set to one of the 16 stored colors.

the store sequence is ^[[8].

so to set the background as black, and the foreground as brightwhite;

printf '\033[40;1;37m\033[8]'

see also; Framebuffer HOWTO, understanding color codes in the terminal