dots

git clone git://mattcarlson.org/repos/dots.git
Log | Files | Refs

commit a548e0ea6fe83b70ca2ce017e03849db6719c17e
parent 809b2a9fc469568e662854a72a65254e9cd6a7f5
Author: Matthew Carlson <matt@mattcarlson.org>
Date:   Mon,  6 Feb 2023 00:34:25 -0500

color script uses picom's new shader interface

Diffstat:
M.local/bin/color.sh | 8++++----
A.local/share/picom/gray.glsl | 16++++++++++++++++
2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/.local/bin/color.sh b/.local/bin/color.sh @@ -8,7 +8,7 @@ COLOR="${XDG_CACHE_HOME:-${HOME}/.cache/}/dots/color" COMPOSITOR='picom' # we can make windows mono via shader -SHADER='uniform sampler2D tex; uniform float opacity; void main() { vec4 c = texture2D(tex, gl_TexCoord[0].xy); float y = dot(c.rgb, vec3(0.2126, 0.7152, 0.0722)); gl_FragColor = opacity*vec4(y, y, y, c.a); }' +SHADER="${XDG_DATA_HOME:-${HOME}/.local/share/}/picom/gray.glsl" start() { # get mode stored in cache @@ -18,13 +18,13 @@ start() { # start compositor [ "${mode}" -eq 1 ] && ${COMPOSITOR} -b \ - || ${COMPOSITOR} -b --backend glx --glx-fshader-win "${SHADER}" 2>/dev/null + || ${COMPOSITOR} -b --backend glx --window-shader-fg="${SHADER}" 2>/dev/null } toggle() { # check shader status and thus check mode #shellcheck disable=SC2009 - shader_id=$(ps -ef | grep 'glx-fshader-win' | grep -iv '\<grep\>' | awk '{ printf "%s ", $2 }') + shader_id=$(ps -ef | grep 'window-shader-fg' | grep -iv '\<grep\>' | awk '{ printf "%s ", $2 }') # shader enabled, meaning mono # ENABLE COLOR @@ -40,7 +40,7 @@ toggle() { #shellcheck disable=SC2086 $(kill ${comp_id} && \ sleep 1 && \ - ${COMPOSITOR} -b --backend glx --glx-fshader-win "${SHADER}" 2>/dev/null) || return 1 + ${COMPOSITOR} -b --backend glx --window-shader-fg="${SHADER}" 2>/dev/null) || return 1 mode=0 fi diff --git a/.local/share/picom/gray.glsl b/.local/share/picom/gray.glsl @@ -0,0 +1,16 @@ +#version 330 + +in vec2 texcoord; +uniform sampler2D tex; +uniform float opacity; + +vec4 default_post_processing(vec4 c); + +vec4 window_shader() { + vec2 texsize = textureSize(tex, 0); + vec4 color = texture2D(tex, texcoord / texsize, 0); + + color = vec4(vec3(0.2126 * color.r + 0.7152 * color.g + 0.0722 * color.b) * opacity, color.a * opacity); + + return default_post_processing(color); +}