zenUtils/grey.sh

45 lines
794 B
Bash
Raw Normal View History

2024-09-26 04:15:43 +00:00
#!/usr/bin/sh
lockfile=/home/nilix/.colormode
if [ ! -e ${lockfile} ]; then
echo "fullcolor" > ${lockfile}
fi
if [ "$1" = "toggle" ]; then
colormode=$(cat ${lockfile})
case ${colormode} in
"fullcolor")
echo "greyscale" > ${lockfile}
;;
"greyscale")
echo "fullcolor" > ${lockfile}
;;
esac
fi
apply_compositor() {
kill $(pgrep picom)
colormode=$(cat ${lockfile})
case ${colormode} in
"fullcolor")
picom &
;;
"greyscale")
picom --legacy-backends --backend glx --glx-fshader-win "
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, c.a);
}" &
;;
esac
}
apply_compositor