From e82682fd7a718b6d6b786b5a0eecdba2ce732ec7 Mon Sep 17 00:00:00 2001 From: chris Date: Mon, 12 Oct 2020 13:12:23 +0200 Subject: [PATCH] toggle black/white filter with picom --- toggle-bw.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 toggle-bw.sh diff --git a/toggle-bw.sh b/toggle-bw.sh new file mode 100755 index 0000000..0a276a3 --- /dev/null +++ b/toggle-bw.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +# 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 --backend glx --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 & +fi