scripts/toggle-bw.sh

23 lines
667 B
Bash
Raw Permalink Normal View History

2020-10-12 11:12:23 +00:00
#!/usr/bin/env bash
2020-10-12 12:30:12 +00:00
PICOM_OPTIONS="--backend glx"
2020-10-12 11:12:23 +00:00
# pgrep returns 0 if a matching process is found, 1 if not.
# Thus 1 means there is either a picom process without b/w filter running,
# or none at all. Either way, display is coloured when return code is 1.
pgrep -fa gl_FragColor &>/dev/null
if [ $? -eq 1 ];
then
pkill picom
2020-10-12 12:30:12 +00:00
picom ${PICOM_OPTIONS} --glx-fshader-win \
2020-10-12 11:12:23 +00:00
"uniform sampler2D tex;
uniform float opacity;
void main() {
vec4 color = texture2D(tex, gl_TexCoord[0].xy);
gl_FragColor = vec4(vec3(0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b) * opacity, color.a * opacity);
}" &
else
pkill picom
2020-10-12 12:30:12 +00:00
picom ${PICOM_OPTIONS} &
2020-10-12 11:12:23 +00:00
fi