picom: transparency for feishin

This commit is contained in:
dogeystamp 2024-06-07 10:59:30 -04:00
parent 7d452da9f1
commit e8308206bf
Signed by: dogeystamp
GPG Key ID: 7225FE3592EFFA38
2 changed files with 56 additions and 1 deletions

View File

@ -0,0 +1,54 @@
// transparency for sonixd and feishin (music player). use "default dark" theme
// https://github.com/ikz87/picom-shaders
#version 330
// rgb value for the maximum transparency
uniform vec3 median_color = vec3(0.063);
// maximum derivation from the median_color of each color channel (rgb)
uniform vec3 max_derivation = vec3(0.40);
// e.g. (1,0,0)±(0.2,0.2,0.2) -> gradient from #c00 to #f00 to #f33 with #f00 being the least opaque
// (0,0,0)±(0.25,0.25,0,25) -> gradient from #000 to #444 with #000 being at min_opacity
// opacity for the median_color
uniform float min_opacity = 0.1;
// exponent for the gradient (e.g. 1 for linear, 2 for quadratic, etc)
uniform int power = 2;
// use mean for a different effect
float get_float (vec3 c) {
// maximum
return max(max(c.r,c.g),c.b);
// mean
// return (v.r + v.g + v.b)/3;
}
// tweak the above variables and functions for your needs
// texture coordinate of the fragment
in vec2 texcoord;
// texture of the window
uniform sampler2D tex;
// Default window post-processing:
// 1) invert color
// 2) opacity / transparency
// 3) max-brightness clamping
// 4) rounded corners
vec4 default_post_processing(vec4 c);
// Default window shader:
// 1) fetch the specified pixel
// 2) apply default post-processing
vec4 window_shader() {
vec4 c = texelFetch(tex, ivec2(texcoord), 0);
// get the each colorchannels derivation from the median_color channels and normalize them
vec3 normalized_derivation = abs(c.rgb - median_color)/max_derivation;
// only add transparency, if the pixel is not already transparent
if (c.a == 1 && get_float(normalized_derivation) < 1) {
// apply the gradient curvature
normalized_derivation = vec3(1)-pow(vec3(1)-normalized_derivation, vec3(power));
// apply transparency to rgb and alpha, because glx uses premultiplied alpha
c *= min_opacity + get_float(normalized_derivation) * (1-min_opacity);
}
return default_post_processing( c );
}

View File

@ -1,4 +1,5 @@
#!/bin/sh
# misc opts so i don't have to use absolute path in picom config
picom --window-shader-fg-rule "$HOME/.config/picom/shaders/transparency.glsl:class_g = 'qutebrowser'"
picom --window-shader-fg-rule "$HOME/.config/picom/shaders/transparency-sonixd.glsl:class_g = 'feishin'" \
--window-shader-fg-rule "$HOME/.config/picom/shaders/transparency.glsl:class_g = 'qutebrowser'" \