An overview of my automatic theming architecture
The basis of the setup is Mustache, a templating system with implementations for a shitload of languages, including bash.
Mustache's structure is simple, with anything inside of {{ two curly braces }} being expanded to the value defined by the user. This allows for use in any configuration file, which is good.
The main system is made of 4 files:
This is what sets the colours used, and does so by exporting them as shell variables to be accessed later by other components of the theming system. All in all, it's pretty simple:
export red=ba3434;
This is done for all of the standard terminal colours (R,G,B,C,Y,M, etc.), and also a foreground and background colour.
A shell script may seem like a rather odd method for configuring a theme, but it offers two main benifits: first, it lets you use any program to define your theme, as long as you can get it's output into a hex form. second, the templating engine that this system uses, mustache, takes its substitution values from environment variables, so this format, when sourced, produces an environment that has all of the definitions in the right form, readily available.
This file is boring, and just contains the list of template files that need to be processed by update.sh.
update.sh is one of the most important scripts. It has two main steps: first run each file through the templating engine. Then, send any messages to programs to tell them their configuration has been changed.
While not a necessary part of the whole system, the daemon is what makes it all so useful. This is a simple script that watches for any changes to theme.sh, and whenever a change occurs runs update.sh. This means that whenever you change theme.sh, the changes are reflected in real time across the whole system