Re: [dev] [st] Hardcoded colors. Can I change them runtime?

From: S. Gilles <sgilles_AT_math.umd.edu>
Date: Wed, 1 Aug 2018 18:38:27 -0400

On 2018-07-30T18:52:11+0200, Timur Fayzrakhmanov wrote:
> Halo!
>
> I've tried to change color scheme using the following project
> https://github.com/chriskempson/base16-shell. But I didn't get a success.
> It seems like the colors are hardcoded at config.def.h and can not be
> changed then. Unfortunately, I don't know well internals of the st nor the
> terminal emulators in general so I hope to get a hint.
> Thank you all.

As others have said, the right way to do this is to change config.h
and recompile. However:

The 256-color palette of st is mutable, since st supports the
can-change-color property. Try something like

        printf '\033]4;0;rgb:10/20/30\033\\'

That should change all black in the current window to a sort of
dark blue. The syntax is

        printf '\033]4;N;rgb:R/G/B\033\\'

where N is a number from 0 to 255 (the color index), and R, G, B
are hex numbers from 0 to ff specifying the intensity of the color.
If you have 256color.pl (or a variation), you can run

    256color.pl
    for x in $(seq 0 255); do
        r=$(head -c 1 /dev/urandom | od -t u1 -A n | tr -d ' ')
        g=$(head -c 1 /dev/urandom | od -t u1 -A n | tr -d ' ')
        b=$(head -c 1 /dev/urandom | od -t u1 -A n | tr -d ' ')
        printf '\033]4;%s;rgb:%2x/%2x/%2x\033\\' ${x} ${r} ${g} ${b}
    done

This is handled in st.c around line 1858, if you want to see more.

-- 
S. Gilles
Received on Thu Aug 02 2018 - 00:38:27 CEST

This archive was generated by hypermail 2.3.0 : Thu Aug 02 2018 - 00:48:06 CEST