compton icon indicating copy to clipboard operation
compton copied to clipboard

Monochrome / Grayscale effect

Open sainathadapa opened this issue 5 years ago • 3 comments

Is it possible to add grayscale effect to specific windows, or the whole display? I can also try helping with the feature, if someone can point me to section where effects like this go.

sainathadapa avatar Nov 30 '18 15:11 sainathadapa

The --glx-fshader-win argument allows this using a suitable GLSL shader, but it's being deprecated. Maybe it's not the cleanest way, but some code from the GLSL shader interpreter bundled with a hard-coded (or externalized but included with e.g. binary packages) grayscale shader could be used to implement monochrome?

kmfrick avatar May 18 '19 23:05 kmfrick

@sainathadapa I used what kmfrick recommended (in case it's helpful, I included my code at the end. To give credit where it is due, I think I found a variant of it on some blog/reddit (that I can't find again), it calculates the Rec 601 Luma from HSL as its monochrome formula. I find it relatively nice to look at for most things (I also found that inverted BW (insert a y=1.0-y line) is really easy on the eyes for coding/reading b/c it makes everything into semi-'dark mode').

@kmfrick I'm sad to hear that it's deprecated, I really love this feature. Can you say any more about how I would go about continuing to use it? Are you saying I could hardcode this GLSL shader into my build of compton (so I just can't pass it as an argument) or is there a file where I could hardcode this formula in/include an external shader?

It might be only kfrick and I that want this but but I think this sort of thing could be interesting to integrate into compton. I find the ability to force a quasi universal dark mode on any application very helpful and increasingly invaluable and compton is (was :cry: ) the only thing I could find that allowed it. I would be happy to discuss more/try to develop a PR.

Thanks!


Main shell script: compton --backend glx --glx-fshader-win "$(cat PATH_TO_GSLS)"

GSLS:

uniform bool invert_color;
uniform sampler2D tex;
void main() {
    vec4 c = texture2D(tex, gl_TexCoord[0].xy);
    float y = dot(c.rgb, vec3(0.299, 0.587, 0.114));
    gl_FragColor = vec4(y, y, y, 1.0);
}

JZL avatar May 29 '19 03:05 JZL

how might you use this to make an inactive window grayscale?

mbartelsm avatar Oct 10 '19 08:10 mbartelsm