colortater is a tool that comes with a GUI version and headless version for automation.
Recently, someone asked me via the feedback form at the bottom of my blog whether I would be okay with them having their blog look similar to mine. I have no exclusive right to the template (it was made by someone else and provided to me for free by Viktor Persson) and I like the spirit of sharing, I gave them the go-ahead.
What I didn't expect was that the pages look so very similar, because there's not really much original design to my blog anyway like a title picture or something. I didn't want the pages to look so stunningly similar, so I decided to change my color scheme.
That's when my lazyness kicked in. I knew there were about five or six places where I'd put small variations of that tone of green that wasn't in the original template and I didn't feel I could just hack the hex codes and get a good-looking result immediately. Therefore I came up with the simplest plan that could possibly work: Create a tool that automatically classifies colors in css style sheets into groups and offer the user to interactively change them. What could go wrong?
This idea was the beginning of a quite fun late night coding session. I sat down with my code editor and the Qt assistant and started hacking. Soon I found out, that it wasn't too fun just to poke around the color values - even though I'd limited myself to just change the hues of colors - so I decided to put in a headless mode, that could be used completely without Qt. This mode is currently advancing the highlight color on my website by 11 degrees every day.
Usage is pretty simple. You just have to run the colortater tool with any number of .css files as arguments. It isn't strictly limited to css files. Any file that would have #RRGGBB, #RGB or rgb(xxx, xxx, xxx) in them should work. Then, the GUI will pop up and you'll be able to change the colors and save it again.
You'll end up with copies of your files with a .src extension. Those will be read the next time you start the program, so if you make any modifications to the actual css, you should change the .src files instead of the .css files.
Now, in the middle of coding, I decided that there's real need for the tool to be runnable from a console without an X server attached or any kind of interactivity. In my case, I wanted to run a cronjob every day to change the color of my website (check back tomorrow or in a week to see the magic happen!). Thus, the -H flag was born.
Typically, you'd first call
colortater -H -g style.css [...]
to find out which groups colortater has found and what their representants are (they are the first color in each line). Then, you can add any number of -a arguments, for example to add 11 degrees to the light green group:
colortater -H -a 4bdc4b 11 style.css [...]
If successful, your files will have been backed up and overwritten with the new, adjusted colors. The changes will stack, so calling this same command over and over will move your colors around and around the hue circle.
If you want to set the adjustment value to a certain value, you can just prepend the number with an equals sign. Don't forget to escape it for your shell if you need to:
colortater -H -a 4bdc4b \=0 style.css [...]