diff --git a/modules/user/hyprland/default.nix b/modules/user/hyprland/default.nix index f47ee82f..6ce13571 100644 --- a/modules/user/hyprland/default.nix +++ b/modules/user/hyprland/default.nix @@ -516,6 +516,7 @@ in qt6.qtwayland xdg-utils wlsunset + hyprshade pavucontrol (pkgs.writeScriptBin "workspace-on-monitor" '' #!/bin/sh @@ -547,6 +548,10 @@ in killall wlsunset &> /dev/null; fi '') + (pkgs.writeScriptBin "scg" '' + #!/bin/sh + hyprshade toggle grayscale; + '') (pkgs.writeScriptBin "obs-notification-mute-daemon" '' #!/bin/sh while true; do @@ -565,6 +570,61 @@ in 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 = '' outputs = "All" position = "Top"