jarcode-foss / glava

GLava - OpenGL audio spectrum visualizer
GNU General Public License v3.0
1.17k stars 59 forks source link

Set background color dynamically #138

Open LiteracyFanatic opened 4 years ago

LiteracyFanatic commented 4 years ago

First off, thank you for the awesome project.

I currently use pywal to set the background color and border color of my terminal windows. I would like do the same thing with glava. So far I have been able to set the color of the bars using the --stdin flag to read from a named pipe which I write the new color to after calling pywal. I'm currently running the stable version of glava, but it looks like the --pipe flag from the git version can be used to set multiple colors. If I understand correctly from reading through the relevant issues however, it looks like this still wouldn't work because setbg is a #request rather than a #define. If possible, I think it would be good to have some way to set the background color dynamically like you can do with the colors in the shaders.

jarcode-foss commented 4 years ago

Ah, I didn't consider this when writing the --pipe flag and bindings. The reason why you currently can't do this is because setbg just sets the values for glClear, when using an opaque buffer, unlike how pipe bindings work (emitting a shader uniform at compile-time).

Also this isn't entirely accurate as to why:

If I understand correctly from reading through the relevant issues however, it looks like this still wouldn't work because setbg is a #request rather than a #define

The --pipe syntax parses and assigns data to GLSL uniforms that are generated with binding syntax inside shader configs and/or sources. You can basically consider these to be an expression that evaluates either to a constant (builtin), or a uniform.

It doesn't actually set any preprocesser directives since that is all generated at compile-time -- just in case you were planning to do anything else with this feature.

The good news is that this is an easy edge case to add so that a certain builtin binding will mutate the colors used by glClear, just as setbg does, but it will have to wait until I am able to merge my local branch since there are some fairly hefty changes pending for the renderer.

LiteracyFanatic commented 4 years ago

Thank you for the explanation. Glad to hear that it is doable. I completely neglected to look at the wiki. Changing the color based on the the output of mpc is a neat idea as well.