scripts/toggle-bw.sh

23 行
667 B
Bash
Executable File

#!/usr/bin/env bash
PICOM_OPTIONS="--backend glx"
# 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
picom ${PICOM_OPTIONS} --glx-fshader-win \
"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
picom ${PICOM_OPTIONS} &
fi