What ways can config.def.h’s colours be automatically populated from an .xpm image file with sed?

I have already stripped a .xpm file to just a list of hex colour codes with grep -oP 'c #K[0-9A-Fa-f]{6}' $1. So perhaps we can start from there, if easier. Seeking how to populate the colours in config.def.h (for whatever) in sequence from a list of hex colours (or from a .xpm image file [~ that format chosen since can read the colours in plain text, and stored as hex]).

Presumably using sed. Not attached to that, though would prefer in standard unix shell tools (not some other programming language[, except bash or fish]).

I’m loosely aware sed can be told ways that are more elaborate as to where to do the edits, like within some paragraph or code section (e.g. only within double quotes within *colorname[] = { or something, probably using sed’s -E for a regex)… but I’ve not found that easy to ascertain how from man page reading or searching (yet~ [though it’s getting very late]), without knowing the terminology needed… and perhaps even then too.

So basically, I have a list, e.g.:

970012
AF7612
D9C112
813E6B
B83212
BD5B12
C08D72
814C59
FF3300
FFBF00
FFF800
CC7EA7
FF5F00
FF9300
FBB171
3E0000
B28567
FF5B00
1E3B1C

which I’d like to populate, in that order, a config file such as:


/*
 * appearance
 *
 * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
 */
static char *font = "nztt:pixelsize=18:antialias=true:autohint=true";
static int borderpx = 2;

/*
 * What program is execed by st depends of these precedence rules:
 * 1: program passed with -e
 * 2: scroll and/or utmp
 * 3: SHELL environment variable
 * 4: value of shell in /etc/passwd
 * 5: value of shell in config.h
 */
static char *shell = "/usr/bin/fish";
char *utmp = NULL;
/* scroll program: to enable use a string like "scroll" */
char *scroll = NULL;
char *stty_args = "stty raw pass8 nl -echo -iexten -cstopb 38400";

/* identification sequence returned in DA and DECID */
char *vtiden = "33[?6c";

/* Kerning / character bounding-box multipliers */
static float cwscale = 1.0;
static float chscale = 1.0;

/*
 * word delimiter string
 *
 * More advanced example: L" `'"()[]{}"
 */
wchar_t *worddelimiters = L" ";

/* selection timeouts (in milliseconds) */
static unsigned int doubleclicktimeout = 300;
static unsigned int tripleclicktimeout = 600;

/* alt screens */
int allowaltscreen = 1;

/* allow certain non-interactive (insecure) window operations such as:
   setting the clipboard text */
int allowwindowops = 0;

/*
 * draw latency range in ms - from new content/keypress/etc until drawing.
 * within this range, st draws when content stops arriving (idle). mostly it's
 * near minlatency, but it waits longer for slow updates to avoid partial draw.
 * low minlatency will tear/flicker more, as it can "detect" idle too early.
 */
static double minlatency = 8;
static double maxlatency = 33;

/*
 * blinking timeout (set to 0 to disable blinking) for the terminal blinking
 * attribute.
 */
static unsigned int blinktimeout = 800;

/*
 * thickness of underline and bar cursors
 */
static unsigned int cursorthickness = 2;

/*
 * bell volume. It must be a value between -100 and 100. Use 0 for disabling
 * it
 */
static int bellvolume = 0;

/* default TERM value */
char *termname = "st-256color";

/*
 * spaces per tab
 *
 * When you are changing this value, don't forget to adapt the »it« value in
 * the st.info and appropriately install the st.info in the environment where
 * you use this st version.
 *
 *  it#$tabspaces,
 *
 * Secondly make sure your kernel is not expanding tabs. When running `stty
 * -a` »tab0« should appear. You can tell the terminal to not expand tabs by
 *  running following command:
 *
 *  stty tabs
 */
unsigned int tabspaces = 8;

/* Terminal colors (16 first used in escape sequence) */
static const char *colorname[] = {
    /* 8 normal colors */
    "#190000",
    "#A50000",
    "#A53800",
    "#A55700",
    "#865757",
    "#861957",
    "#A51900",
    "#D3B457",

    /* 8 bright colors */
    "#955738",
    "#ff0000",
    "#ff9500",
    "#ffee00",
    "#e29595",
    "#e238a4",
    "#ff5700",
    "#ffc357",

    [255] = 0,

    /* more colors can be added after 255 to use with DefaultXX */
    "#e2c3a4",
    "#955738",
    "#e2a457", /* default foreground colour */
    "black", /* default background colour */
};


/*
 * Default colors (colorname index)
 * foreground, background, cursor, reverse cursor
 */
unsigned int defaultfg = 258;
unsigned int defaultbg = 259;
unsigned int defaultcs = 256;
static unsigned int defaultrcs = 257;

/*
 * Default shape of cursor
 * 2: Block ("█")
 * 4: Underline ("_")
 * 6: Bar ("|")
 * 7: Snowman ("☃")
 */
static unsigned int cursorshape = 2;

/*
 * Default columns and rows numbers
 */

static unsigned int cols = 80;
static unsigned int rows = 24;

/*
 * Default colour and shape of the mouse cursor
 */
static unsigned int mouseshape = XC_xterm;
static unsigned int mousefg = 7;
static unsigned int mousebg = 0;

/*
 * Color used to display font attributes when fontconfig selected a font which
 * doesn't match the ones requested.
 */
static unsigned int defaultattr = 11;

/*
 * Force mouse select/shortcuts while mask is active (when MODE_MOUSE is set).
 * Note that if you want to use ShiftMask with selmasks, set this to an other
 * modifier, set to 0 to not use it.
 */
static uint forcemousemod = ShiftMask;

/*
 * Internal mouse shortcuts.
 * Beware that overloading Button1 will disable the selection.
 */
static MouseShortcut mshortcuts[] = {
    /* mask                 button   function        argument       release */
    { XK_ANY_MOD,           Button2, selpaste,       {.i = 0},      1 },
    { ShiftMask,            Button4, ttysend,        {.s = "33[5;2~"} },
    { XK_ANY_MOD,           Button4, ttysend,        {.s = "31"} },
    { ShiftMask,            Button5, ttysend,        {.s = "33[6;2~"} },
    { XK_ANY_MOD,           Button5, ttysend,        {.s = "05"} },
};

/* Internal keyboard shortcuts. */
#define MODKEY Mod1Mask
#define TERMMOD (ControlMask|ShiftMask)

static Shortcut shortcuts[] = {
    /* mask                 keysym          function        argument */
    { XK_ANY_MOD,           XK_Break,       sendbreak,      {.i =  0} },
    { ControlMask,          XK_Print,       toggleprinter,  {.i =  0} },
    { ShiftMask,            XK_Print,       printscreen,    {.i =  0} },
    { XK_ANY_MOD,           XK_Print,       printsel,       {.i =  0} },
    { TERMMOD,              XK_Prior,       zoom,           {.f = +1} },
    { TERMMOD,              XK_Next,        zoom,           {.f = -1} },
    { TERMMOD,              XK_Home,        zoomreset,      {.f =  0} },
    { TERMMOD,              XK_C,           clipcopy,       {.i =  0} },
    { TERMMOD,              XK_V,           clippaste,      {.i =  0} },
    { TERMMOD,              XK_Y,           selpaste,       {.i =  0} },
    { ShiftMask,            XK_Insert,      selpaste,       {.i =  0} },
    { TERMMOD,              XK_Num_Lock,    numlock,        {.i =  0} },
    { ShiftMask,            XK_Page_Up,     kscrollup,      {.i = -1} },
    { ShiftMask,            XK_Page_Down,   kscrolldown,    {.i = -1} },
};

/*
 * Special keys (change & recompile st.info accordingly)
 *
 * Mask value:
 * * Use XK_ANY_MOD to match the key no matter modifiers state
 * * Use XK_NO_MOD to match the key alone (no modifiers)
 * appkey value:
 * * 0: no value
 * * > 0: keypad application mode enabled
 * *   = 2: term.numlock = 1
 * * < 0: keypad application mode disabled
 * appcursor value:
 * * 0: no value
 * * > 0: cursor application mode enabled
 * * < 0: cursor application mode disabled
 *
 * Be careful with the order of the definitions because st searches in
 * this table sequentially, so any XK_ANY_MOD must be in the last
 * position for a key.
 */

/*
 * If you want keys other than the X11 function keys (0xFD00 - 0xFFFF)
 * to be mapped below, add them to this array.
 */
static KeySym mappedkeys[] = { -1 };

/*
 * State bits to ignore when matching key or button events.  By default,
 * numlock (Mod2Mask) and keyboard layout (XK_SWITCH_MOD) are ignored.
 */
static uint ignoremod = Mod2Mask|XK_SWITCH_MOD;

/*
 * This is the huge key array which defines all compatibility to the Linux
 * world. Please decide about changes wisely.
 */
static Key key[] = {
    /* keysym           mask            string      appkey appcursor */
    { XK_KP_Home,       ShiftMask,      "33[2J",       0,   -1},
    { XK_KP_Home,       ShiftMask,      "33[1;2H",     0,   +1},
    { XK_KP_Home,       XK_ANY_MOD,     "33[H",        0,   -1},
    { XK_KP_Home,       XK_ANY_MOD,     "33[1~",       0,   +1},
    { XK_KP_Up,         XK_ANY_MOD,     "33Ox",       +1,    0},
    { XK_KP_Up,         XK_ANY_MOD,     "33[A",        0,   -1},
    { XK_KP_Up,         XK_ANY_MOD,     "33OA",        0,   +1},
    { XK_KP_Down,       XK_ANY_MOD,     "33Or",       +1,    0},
    { XK_KP_Down,       XK_ANY_MOD,     "33[B",        0,   -1},
    { XK_KP_Down,       XK_ANY_MOD,     "33OB",        0,   +1},
    { XK_KP_Left,       XK_ANY_MOD,     "33Ot",       +1,    0},
    { XK_KP_Left,       XK_ANY_MOD,     "33[D",        0,   -1},
    { XK_KP_Left,       XK_ANY_MOD,     "33OD",        0,   +1},
    { XK_KP_Right,      XK_ANY_MOD,     "33Ov",       +1,    0},
    { XK_KP_Right,      XK_ANY_MOD,     "33[C",        0,   -1},
    { XK_KP_Right,      XK_ANY_MOD,     "33OC",        0,   +1},
    { XK_KP_Prior,      ShiftMask,      "33[5;2~",     0,    0},
    { XK_KP_Prior,      XK_ANY_MOD,     "33[5~",       0,    0},
    { XK_KP_Begin,      XK_ANY_MOD,     "33[E",        0,    0},
    { XK_KP_End,        ControlMask,    "33[J",       -1,    0},
    { XK_KP_End,        ControlMask,    "33[1;5F",    +1,    0},
    { XK_KP_End,        ShiftMask,      "33[K",       -1,    0},
    { XK_KP_End,        ShiftMask,      "33[1;2F",    +1,    0},
    { XK_KP_End,        XK_ANY_MOD,     "33[4~",       0,    0},
    { XK_KP_Next,       ShiftMask,      "33[6;2~",     0,    0},
    { XK_KP_Next,       XK_ANY_MOD,     "33[6~",       0,    0},
    { XK_KP_Insert,     ShiftMask,      "33[2;2~",    +1,    0},
    { XK_KP_Insert,     ShiftMask,      "33[4l",      -1,    0},
    { XK_KP_Insert,     ControlMask,    "33[L",       -1,    0},
    { XK_KP_Insert,     ControlMask,    "33[2;5~",    +1,    0},
    { XK_KP_Insert,     XK_ANY_MOD,     "33[4h",      -1,    0},
    { XK_KP_Insert,     XK_ANY_MOD,     "33[2~",      +1,    0},
    { XK_KP_Delete,     ControlMask,    "33[M",       -1,    0},
    { XK_KP_Delete,     ControlMask,    "33[3;5~",    +1,    0},
    { XK_KP_Delete,     ShiftMask,      "33[2K",      -1,    0},
    { XK_KP_Delete,     ShiftMask,      "33[3;2~",    +1,    0},
    { XK_KP_Delete,     XK_ANY_MOD,     "33[P",       -1,    0},
    { XK_KP_Delete,     XK_ANY_MOD,     "33[3~",      +1,    0},
    { XK_KP_Multiply,   XK_ANY_MOD,     "33Oj",       +2,    0},
    { XK_KP_Add,        XK_ANY_MOD,     "33Ok",       +2,    0},
    { XK_KP_Enter,      XK_ANY_MOD,     "33OM",       +2,    0},
    { XK_KP_Enter,      XK_ANY_MOD,     "r",           -1,    0},
    { XK_KP_Subtract,   XK_ANY_MOD,     "33Om",       +2,    0},
    { XK_KP_Decimal,    XK_ANY_MOD,     "33On",       +2,    0},
    { XK_KP_Divide,     XK_ANY_MOD,     "33Oo",       +2,    0},
    { XK_KP_0,          XK_ANY_MOD,     "33Op",       +2,    0},
    { XK_KP_1,          XK_ANY_MOD,     "33Oq",       +2,    0},
    { XK_KP_2,          XK_ANY_MOD,     "33Or",       +2,    0},
    { XK_KP_3,          XK_ANY_MOD,     "33Os",       +2,    0},
    { XK_KP_4,          XK_ANY_MOD,     "33Ot",       +2,    0},
    { XK_KP_5,          XK_ANY_MOD,     "33Ou",       +2,    0},
    { XK_KP_6,          XK_ANY_MOD,     "33Ov",       +2,    0},
    { XK_KP_7,          XK_ANY_MOD,     "33Ow",       +2,    0},
    { XK_KP_8,          XK_ANY_MOD,     "33Ox",       +2,    0},
    { XK_KP_9,          XK_ANY_MOD,     "33Oy",       +2,    0},
    { XK_Up,            ShiftMask,      "33[1;2A",     0,    0},
    { XK_Up,            Mod1Mask,       "33[1;3A",     0,    0},
    { XK_Up,         ShiftMask|Mod1Mask,"33[1;4A",     0,    0},
    { XK_Up,            ControlMask,    "33[1;5A",     0,    0},
    { XK_Up,      ShiftMask|ControlMask,"33[1;6A",     0,    0},
    { XK_Up,       ControlMask|Mod1Mask,"33[1;7A",     0,    0},
    { XK_Up,ShiftMask|ControlMask|Mod1Mask,"33[1;8A",  0,    0},
    { XK_Up,            XK_ANY_MOD,     "33[A",        0,   -1},
    { XK_Up,            XK_ANY_MOD,     "33OA",        0,   +1},
    { XK_Down,          ShiftMask,      "33[1;2B",     0,    0},
    { XK_Down,          Mod1Mask,       "33[1;3B",     0,    0},
    { XK_Down,       ShiftMask|Mod1Mask,"33[1;4B",     0,    0},
    { XK_Down,          ControlMask,    "33[1;5B",     0,    0},
    { XK_Down,    ShiftMask|ControlMask,"33[1;6B",     0,    0},
    { XK_Down,     ControlMask|Mod1Mask,"33[1;7B",     0,    0},
    { XK_Down,ShiftMask|ControlMask|Mod1Mask,"33[1;8B",0,    0},
    { XK_Down,          XK_ANY_MOD,     "33[B",        0,   -1},
    { XK_Down,          XK_ANY_MOD,     "33OB",        0,   +1},
    { XK_Left,          ShiftMask,      "33[1;2D",     0,    0},
    { XK_Left,          Mod1Mask,       "33[1;3D",     0,    0},
    { XK_Left,       ShiftMask|Mod1Mask,"33[1;4D",     0,    0},
    { XK_Left,          ControlMask,    "33[1;5D",     0,    0},
    { XK_Left,    ShiftMask|ControlMask,"33[1;6D",     0,    0},
    { XK_Left,     ControlMask|Mod1Mask,"33[1;7D",     0,    0},
    { XK_Left,ShiftMask|ControlMask|Mod1Mask,"33[1;8D",0,    0},
    { XK_Left,          XK_ANY_MOD,     "33[D",        0,   -1},
    { XK_Left,          XK_ANY_MOD,     "33OD",        0,   +1},
    { XK_Right,         ShiftMask,      "33[1;2C",     0,    0},
    { XK_Right,         Mod1Mask,       "33[1;3C",     0,    0},
    { XK_Right,      ShiftMask|Mod1Mask,"33[1;4C",     0,    0},
    { XK_Right,         ControlMask,    "33[1;5C",     0,    0},
    { XK_Right,   ShiftMask|ControlMask,"33[1;6C",     0,    0},
    { XK_Right,    ControlMask|Mod1Mask,"33[1;7C",     0,    0},
    { XK_Right,ShiftMask|ControlMask|Mod1Mask,"33[1;8C",0,   0},
    { XK_Right,         XK_ANY_MOD,     "33[C",        0,   -1},
    { XK_Right,         XK_ANY_MOD,     "33OC",        0,   +1},
    { XK_ISO_Left_Tab,  ShiftMask,      "33[Z",        0,    0},
    { XK_Return,        Mod1Mask,       "33r",        0,    0},
    { XK_Return,        XK_ANY_MOD,     "r",            0,    0},
    { XK_Insert,        ShiftMask,      "33[4l",      -1,    0},
    { XK_Insert,        ShiftMask,      "33[2;2~",    +1,    0},
    { XK_Insert,        ControlMask,    "33[L",       -1,    0},
    { XK_Insert,        ControlMask,    "33[2;5~",    +1,    0},
    { XK_Insert,        XK_ANY_MOD,     "33[4h",      -1,    0},
    { XK_Insert,        XK_ANY_MOD,     "33[2~",      +1,    0},
    { XK_Delete,        ControlMask,    "33[M",       -1,    0},
    { XK_Delete,        ControlMask,    "33[3;5~",    +1,    0},
    { XK_Delete,        ShiftMask,      "33[2K",      -1,    0},
    { XK_Delete,        ShiftMask,      "33[3;2~",    +1,    0},
    { XK_Delete,        XK_ANY_MOD,     "33[P",       -1,    0},
    { XK_Delete,        XK_ANY_MOD,     "33[3~",      +1,    0},
    { XK_BackSpace,     XK_NO_MOD,      "177",          0,    0},
    { XK_BackSpace,     Mod1Mask,       "33177",      0,    0},
    { XK_Home,          ShiftMask,      "33[2J",       0,   -1},
    { XK_Home,          ShiftMask,      "33[1;2H",     0,   +1},
    { XK_Home,          XK_ANY_MOD,     "33[H",        0,   -1},
    { XK_Home,          XK_ANY_MOD,     "33[1~",       0,   +1},
    { XK_End,           ControlMask,    "33[J",       -1,    0},
    { XK_End,           ControlMask,    "33[1;5F",    +1,    0},
    { XK_End,           ShiftMask,      "33[K",       -1,    0},
    { XK_End,           ShiftMask,      "33[1;2F",    +1,    0},
    { XK_End,           XK_ANY_MOD,     "33[4~",       0,    0},
    { XK_Prior,         ControlMask,    "33[5;5~",     0,    0},
    { XK_Prior,         ShiftMask,      "33[5;2~",     0,    0},
    { XK_Prior,         XK_ANY_MOD,     "33[5~",       0,    0},
    { XK_Next,          ControlMask,    "33[6;5~",     0,    0},
    { XK_Next,          ShiftMask,      "33[6;2~",     0,    0},
    { XK_Next,          XK_ANY_MOD,     "33[6~",       0,    0},
    { XK_F1,            XK_NO_MOD,      "33OP" ,       0,    0},
    { XK_F1, /* F13 */  ShiftMask,      "33[1;2P",     0,    0},
    { XK_F1, /* F25 */  ControlMask,    "33[1;5P",     0,    0},
    { XK_F1, /* F37 */  Mod4Mask,       "33[1;6P",     0,    0},
    { XK_F1, /* F49 */  Mod1Mask,       "33[1;3P",     0,    0},
    { XK_F1, /* F61 */  Mod3Mask,       "33[1;4P",     0,    0},
    { XK_F2,            XK_NO_MOD,      "33OQ" ,       0,    0},
    { XK_F2, /* F14 */  ShiftMask,      "33[1;2Q",     0,    0},
    { XK_F2, /* F26 */  ControlMask,    "33[1;5Q",     0,    0},
    { XK_F2, /* F38 */  Mod4Mask,       "33[1;6Q",     0,    0},
    { XK_F2, /* F50 */  Mod1Mask,       "33[1;3Q",     0,    0},
    { XK_F2, /* F62 */  Mod3Mask,       "33[1;4Q",     0,    0},
    { XK_F3,            XK_NO_MOD,      "33OR" ,       0,    0},
    { XK_F3, /* F15 */  ShiftMask,      "33[1;2R",     0,    0},
    { XK_F3, /* F27 */  ControlMask,    "33[1;5R",     0,    0},
    { XK_F3, /* F39 */  Mod4Mask,       "33[1;6R",     0,    0},
    { XK_F3, /* F51 */  Mod1Mask,       "33[1;3R",     0,    0},
    { XK_F3, /* F63 */  Mod3Mask,       "33[1;4R",     0,    0},
    { XK_F4,            XK_NO_MOD,      "33OS" ,       0,    0},
    { XK_F4, /* F16 */  ShiftMask,      "33[1;2S",     0,    0},
    { XK_F4, /* F28 */  ControlMask,    "33[1;5S",     0,    0},
    { XK_F4, /* F40 */  Mod4Mask,       "33[1;6S",     0,    0},
    { XK_F4, /* F52 */  Mod1Mask,       "33[1;3S",     0,    0},
    { XK_F5,            XK_NO_MOD,      "33[15~",      0,    0},
    { XK_F5, /* F17 */  ShiftMask,      "33[15;2~",    0,    0},
    { XK_F5, /* F29 */  ControlMask,    "33[15;5~",    0,    0},
    { XK_F5, /* F41 */  Mod4Mask,       "33[15;6~",    0,    0},
    { XK_F5, /* F53 */  Mod1Mask,       "33[15;3~",    0,    0},
    { XK_F6,            XK_NO_MOD,      "33[17~",      0,    0},
    { XK_F6, /* F18 */  ShiftMask,      "33[17;2~",    0,    0},
    { XK_F6, /* F30 */  ControlMask,    "33[17;5~",    0,    0},
    { XK_F6, /* F42 */  Mod4Mask,       "33[17;6~",    0,    0},
    { XK_F6, /* F54 */  Mod1Mask,       "33[17;3~",    0,    0},
    { XK_F7,            XK_NO_MOD,      "33[18~",      0,    0},
    { XK_F7, /* F19 */  ShiftMask,      "33[18;2~",    0,    0},
    { XK_F7, /* F31 */  ControlMask,    "33[18;5~",    0,    0},
    { XK_F7, /* F43 */  Mod4Mask,       "33[18;6~",    0,    0},
    { XK_F7, /* F55 */  Mod1Mask,       "33[18;3~",    0,    0},
    { XK_F8,            XK_NO_MOD,      "33[19~",      0,    0},
    { XK_F8, /* F20 */  ShiftMask,      "33[19;2~",    0,    0},
    { XK_F8, /* F32 */  ControlMask,    "33[19;5~",    0,    0},
    { XK_F8, /* F44 */  Mod4Mask,       "33[19;6~",    0,    0},
    { XK_F8, /* F56 */  Mod1Mask,       "33[19;3~",    0,    0},
    { XK_F9,            XK_NO_MOD,      "33[20~",      0,    0},
    { XK_F9, /* F21 */  ShiftMask,      "33[20;2~",    0,    0},
    { XK_F9, /* F33 */  ControlMask,    "33[20;5~",    0,    0},
    { XK_F9, /* F45 */  Mod4Mask,       "33[20;6~",    0,    0},
    { XK_F9, /* F57 */  Mod1Mask,       "33[20;3~",    0,    0},
    { XK_F10,           XK_NO_MOD,      "33[21~",      0,    0},
    { XK_F10, /* F22 */ ShiftMask,      "33[21;2~",    0,    0},
    { XK_F10, /* F34 */ ControlMask,    "33[21;5~",    0,    0},
    { XK_F10, /* F46 */ Mod4Mask,       "33[21;6~",    0,    0},
    { XK_F10, /* F58 */ Mod1Mask,       "33[21;3~",    0,    0},
    { XK_F11,           XK_NO_MOD,      "33[23~",      0,    0},
    { XK_F11, /* F23 */ ShiftMask,      "33[23;2~",    0,    0},
    { XK_F11, /* F35 */ ControlMask,    "33[23;5~",    0,    0},
    { XK_F11, /* F47 */ Mod4Mask,       "33[23;6~",    0,    0},
    { XK_F11, /* F59 */ Mod1Mask,       "33[23;3~",    0,    0},
    { XK_F12,           XK_NO_MOD,      "33[24~",      0,    0},
    { XK_F12, /* F24 */ ShiftMask,      "33[24;2~",    0,    0},
    { XK_F12, /* F36 */ ControlMask,    "33[24;5~",    0,    0},
    { XK_F12, /* F48 */ Mod4Mask,       "33[24;6~",    0,    0},
    { XK_F12, /* F60 */ Mod1Mask,       "33[24;3~",    0,    0},
    { XK_F13,           XK_NO_MOD,      "33[1;2P",     0,    0},
    { XK_F14,           XK_NO_MOD,      "33[1;2Q",     0,    0},
    { XK_F15,           XK_NO_MOD,      "33[1;2R",     0,    0},
    { XK_F16,           XK_NO_MOD,      "33[1;2S",     0,    0},
    { XK_F17,           XK_NO_MOD,      "33[15;2~",    0,    0},
    { XK_F18,           XK_NO_MOD,      "33[17;2~",    0,    0},
    { XK_F19,           XK_NO_MOD,      "33[18;2~",    0,    0},
    { XK_F20,           XK_NO_MOD,      "33[19;2~",    0,    0},
    { XK_F21,           XK_NO_MOD,      "33[20;2~",    0,    0},
    { XK_F22,           XK_NO_MOD,      "33[21;2~",    0,    0},
    { XK_F23,           XK_NO_MOD,      "33[23;2~",    0,    0},
    { XK_F24,           XK_NO_MOD,      "33[24;2~",    0,    0},
    { XK_F25,           XK_NO_MOD,      "33[1;5P",     0,    0},
    { XK_F26,           XK_NO_MOD,      "33[1;5Q",     0,    0},
    { XK_F27,           XK_NO_MOD,      "33[1;5R",     0,    0},
    { XK_F28,           XK_NO_MOD,      "33[1;5S",     0,    0},
    { XK_F29,           XK_NO_MOD,      "33[15;5~",    0,    0},
    { XK_F30,           XK_NO_MOD,      "33[17;5~",    0,    0},
    { XK_F31,           XK_NO_MOD,      "33[18;5~",    0,    0},
    { XK_F32,           XK_NO_MOD,      "33[19;5~",    0,    0},
    { XK_F33,           XK_NO_MOD,      "33[20;5~",    0,    0},
    { XK_F34,           XK_NO_MOD,      "33[21;5~",    0,    0},
    { XK_F35,           XK_NO_MOD,      "33[23;5~",    0,    0},
};

/*
 * Selection types' masks.
 * Use the same masks as usual.
 * Button1Mask is always unset, to make masks match between ButtonPress.
 * ButtonRelease and MotionNotify.
 * If no match is found, regular selection is used.
 */
static uint selmasks[] = {
    [SEL_RECTANGULAR] = Mod1Mask,
};

/*
 * Printable characters in ASCII, used to estimate the advance width
 * of single wide characters.
 */
static char ascii_printable[] =
    " !"#$%&'()*+,-./0123456789:;<=>?"
    "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_"
    "`abcdefghijklmnopqrstuvwxyz{|}~";

I’ve wrestled LLM back and forth for a couple bouts of multiple hours, trying to get sense, but the scripts it offered keep erroring. I suspect because [not entirely its fault] I struggle to frame the question correctly, even when breaking it down to smaller parts. Please advise how I can improve this question/terminology.

And if the question is fine as is, I welcome any tips how to tell sed (or something else?) to populate a config like this where there are existing hex colours in quotes.

And, for bonus, have it unbothered by one (or more) of the pre-existing colour codes in the config not being hex (e.g. as in example “black”).

While this example is for st, I’ve intended this script to work for dwm, dmenu, and others too.
~ (didn’t intend to rack up over day on it and still stuck no further despite the busy churn through many versions and different avenues (did originally start with .ppm (since it too can be cat i.ppm) and converted rrr,ggg,bbb to hex (though, not properly yet ~ small off-by-2 bugs), before finding xpm already in hex)).

How can I script up populating a config’s colours with a list of colours (/ from .xpm image file)?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật