Grayscale improves focus?

This commit is contained in:
Emmet
2025-07-15 12:52:25 -05:00
parent 6b07446f4a
commit f86049f259

View File

@ -516,6 +516,7 @@ in
qt6.qtwayland qt6.qtwayland
xdg-utils xdg-utils
wlsunset wlsunset
hyprshade
pavucontrol pavucontrol
(pkgs.writeScriptBin "workspace-on-monitor" '' (pkgs.writeScriptBin "workspace-on-monitor" ''
#!/bin/sh #!/bin/sh
@ -547,6 +548,10 @@ in
killall wlsunset &> /dev/null; killall wlsunset &> /dev/null;
fi fi
'') '')
(pkgs.writeScriptBin "scg" ''
#!/bin/sh
hyprshade toggle grayscale;
'')
(pkgs.writeScriptBin "obs-notification-mute-daemon" '' (pkgs.writeScriptBin "obs-notification-mute-daemon" ''
#!/bin/sh #!/bin/sh
while true; do while true; do
@ -565,6 +570,61 @@ in
then echo "Shouldn't suspend"; sleep 10; else echo "Should suspend"; systemctl suspend; fi then echo "Shouldn't suspend"; sleep 10; else echo "Should suspend"; systemctl suspend; fi
'') '')
]); ]);
home.file.".config/hypr/shaders/grayscale.glsl".text = ''
/*
* Grayscale
*/
precision highp float;
varying vec2 v_texcoord;
uniform sampler2D tex;
// Enum for type of grayscale conversion
const int LUMINOSITY = 0;
const int LIGHTNESS = 1;
const int AVERAGE = 2;
/**
* Type of grayscale conversion.
*/
const int Type = LUMINOSITY;
// Enum for selecting luma coefficients
const int PAL = 0;
const int HDTV = 1;
const int HDR = 2;
/**
* Formula used to calculate relative luminance.
* (Only applies to type = "luminosity".)
*/
const int LuminosityType = HDR;
void main() {
vec4 pixColor = texture2D(tex, v_texcoord);
float gray;
if (Type == LUMINOSITY) {
// https://en.wikipedia.org/wiki/Grayscale#Luma_coding_in_video_systems
if (LuminosityType == PAL) {
gray = dot(pixColor.rgb, vec3(0.299, 0.587, 0.114));
} else if (LuminosityType == HDTV) {
gray = dot(pixColor.rgb, vec3(0.2126, 0.7152, 0.0722));
} else if (LuminosityType == HDR) {
gray = dot(pixColor.rgb, vec3(0.2627, 0.6780, 0.0593));
}
} else if (Type == LIGHTNESS) {
float maxPixColor = max(pixColor.r, max(pixColor.g, pixColor.b));
float minPixColor = min(pixColor.r, min(pixColor.g, pixColor.b));
gray = (maxPixColor + minPixColor) / 2.0;
} else if (Type == AVERAGE) {
gray = (pixColor.r + pixColor.g + pixColor.b) / 3.0;
}
vec3 grayscale = vec3(gray);
gl_FragColor = vec4(grayscale, pixColor.a);
}
'';
home.file.".config/ashell/config.toml".text = '' home.file.".config/ashell/config.toml".text = ''
outputs = "All" outputs = "All"
position = "Top" position = "Top"