Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monochrome / Grayscale effect #530

Open
sainathadapa opened this issue Nov 30, 2018 · 3 comments
Open

Monochrome / Grayscale effect #530

sainathadapa opened this issue Nov 30, 2018 · 3 comments

Comments

@sainathadapa
Copy link

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.

@kmfrick
Copy link

kmfrick commented May 18, 2019

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?

@JZL
Copy link

JZL commented May 29, 2019

@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 😢 ) 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);
}

@mbartelsm
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants