5

I want to use st with solarized colors like I can with urxvt (of course this is done via .Xresources, in st the colors are defined in a header file). I've tried to put the colors in st's config file (config.h), but the colors are "used for the wrong things" in st (eg. dircolors and colors in vim are rearranged relative to urxvt).

I think I have to modify the escape sequences used by st, but I'm not getting anywhere. Can anyone offer me a hint on how to apply the solarized colors to st?

JdeBP
  • 68,745

4 Answers4

3

For those wanting an example of st's config.h with Solarized colours see his Gist: https://gist.github.com/gregf/5279175

Anthon
  • 79,293
chris
  • 131
1

Solarized is now available as an official patch against config.def.h:

https://st.suckless.org/patches/solarized/

jncraton
  • 166
1

I have no prior experience with st other than using it, but from glancing at the source I think I have found the parts that are relevant.
I presumed that by use solarized colors you meant that you want all applications that use default blue to instead use solarized blue.

You will need to make some changes to the source in st.c rather than just config.h.
dc is a global variable that is an instance of the DC struct, each dc.cols[i] corresponds to a color to use.

The first 16 colors within config.h colorname are loaded via XAllocNamedcolor within the function xloadcols(void), these are inserted into the first 16 positions (0 to 15) within dc.col.

These correspond to ansi escape sequence colours, for more see ANSI Escape Code::Colors.

You would need to change this funtionality within xloadcols(void), specifically the first for loop.
Instead of using XAllocNamedColor you could instead use XAllocColor (you can see an example of this in the second for loop), this allows you to specify the rgb of each color to be inserted at each position (instead of loading an already known colour from a name).

For the hex values see solarized.vim specifically lines 98 through 116 where the hex values are specified.

The rest of dc.cols is allocated within a for loop, also found within xloadcols(void), you probably shouldn't need to change this although it means some applications may use these colors rather than your solarized ones.

As for the default background and foreground colors these are set within config.h, lines 40 and below.
each #define name index defines dc.col[index] is to be used for name, for example DefaultBg specifies the background color of the terminal.

cjh
  • 1,559
0

In st tip (and the 0.3 release) it's not necessary to edit st.c, just insert the solarized colors in config.h. It seems that both st.c and config.h has changed since I asked this question.