So I finally wrote a piece of code =w=
Wellll I mean it’s just bash, but still! I’m pretty proud of this one. So, viscolourchanger is a program that takes colourschemes generated by pywal, automatically adds them to a cli-visualiser (herein referred to as ‘vis’) colour config file, and reloads vis.
That’s pretty much it. It’s pretty simple, but it works really well when added to a wrapper for wal:
click here to check it out or poke around!
How it Works:
So the first thing viscolourchanger does is to source the current wal colour scheme, which sources the variables in colors.sh.
At first I had it written such that each colour variable from the wal shell file would be added to vis’ config with a # at the front, mimicking the existing colour scheme formats, but as it turns out that gives you two hashtags, and if you just send it the plain colour codes it adds the hashtags automatically. So by the end you end up with the current form which is just
cat > $HOME/.config/vis/colors/wal <<CONF $color1 $color2 $color3 ... CONF
As for the choice of colours however, I just chose the first twelve colours from wal and wrote them in order. With the exception of $background and $foreground, there seems to be very little pattern to the order of colours in wal’s colour schemes. Hence, I just dumped them in there and that was that. If anyone wanted to however, they could just rearrange those colours (or add different ones included in the wal scheme) and it’d work just as well.
So by this point, the new colour scheme has been fully generated in vis’ config file, and with the aforementioned tweaking, everything is ready. Finally, viscolourchanger runs
killall -USR1 vis
which tells vis to reload (yeah, killall actually does a lot more than what it says on the can). Vis will now run using the new colour scheme!
Last thing to mention is that, without further work, viscolourchanger, vis and wal are all separate programs. To use them together, it’s useful to make a small wrapper to run them all together. You then put the wrapper in /usr/local/bin or higher so it runs instead of the original wal program. My wrapper is simply:
#!/bin/bash # this wrapper should go in your /usr/local/bin or higher in order to supercede the default "wal" command. /usr/bin/wal $@ # genzathurarc (this is just another thing i wrapped it with, dw about this bit) viscolourchanger
So it runs the original wal (and therefore sets up a new colour scheme if called), then just runs viscolourchanger which imports the colour scheme and reloads vis.
That’s it! It’s not much, but I’m really proud of myself for making this. Also, big thanks to Lynne for helping me when I had questions!