Fixing Suckless Terminal + Pywal Background Bug

Published on

#The Problem

In my ongoing quest to incorporate pywal’s colors into all my applications, I came across a bug in suckless terminal, AKA st.

pywal keeps track of 16 terminal colors in addition to an extra, special color known as background.

However, by default, st uses terminal color 0 as the background color. You may not even notice a difference– in fact, for some of builtin pywal colorschemes, terminal color 0 and background are equivalent.


Inside the source code of st is the culprit of this problem:



 * Default colors (colorname index)
 * foreground, background, cursor, reverse cursor
unsigned int defaultfg = 7;
unsigned int defaultbg = 0;

defaultbg is set to terminal color 0. However, pywal sets the background value to index 232:



# Special colors.
# Source: https://goo.gl/KcoQgP
# 10 = foreground, 11 = background, 12 = cursor foregound
# 13 = mouse foreground, 708 = background border color.
set_special(10, colors["special"]["foreground"], "g"),
set_special(11, colors["special"]["background"], "h", alpha),
set_special(12, colors["special"]["cursor"], "l"),
set_special(13, colors["special"]["foreground"], "l"),
set_special(17, colors["special"]["foreground"], "l"),
set_special(19, colors["special"]["background"], "l"),
set_color(232, colors["special"]["background"]),
set_color(256, colors["special"]["foreground"])

Therefor, in order to fix the mismatch, simply change defaultbg in st/config.h to 232.

Meet the Author

John Allbritten

Nashville, TN

I love learning new technologies, and I have a passion for open source. As I learn things, my notes turn into articles to share.

Keep Reading