Shader error when used in hypridle on hyprland 0.50+
So I upgraded to the new hyprland and then hyproled would throw errors. I fixed it by using the updated AUR package after cleaning paru cache. however, when the hyproled is triggered with hypridle, it throws the following error:
Screen shader parser: Error compiling shader: 0:17(1): error: syntax error, unexpected '}', expecting end of file. Hyprland may not work correctly.
I am not sure why it is only erring when used with hypridle but that is what is happening so far. When I downgrade hyprland back to 0.48 and then build hyproled from the previous commit then it works there from command line and from hypridle. So I am unsure what changed in 0.50 that allows command line to work but not hypridle trigger.
hey I will have a look. could you provide me the hypridle config / command used to trigger hyproled.
hey I will have a look. could you provide me the hypridle config / command used to trigger hyproled.
listener { timeout = 60 on-timeout = hyproled on-resume = hyproled off }
I just have it set to this! It is very strange since it works perfectly manually doing it, but when I wait one minute and observe, the error comes up. restarting gets rid of the error, and then manually attempting still works. So I have no clue what is at play there!
please try the latest version and report if the bug was fixed. thank you!
please try the latest version and report if the bug was fixed. thank you!
Looks like it still doesn't work! Manual invocation in a user terminal seems fine. I just run hyproled and it will turn off the pixels, then hyproled off turns the shader off, and that works just fine as expected. However, upon the hypridle timeout being reached, I see
please try the latest version and report if the bug was fixed. thank you!
OK so I had some success figuring out why it doesn't work, although I have not been able to implement a fix really. So maybe you'd be able to figure out why it is messed up.
After manually running hyproled:
cat /dev/shm/hyproled_shader.glsl
#version 300 es
precision highp float;
in vec2 v_texcoord;
uniform sampler2D tex;
uniform int wl_output;
layout(location = 0) out vec4 fragColor;
void main(){
vec4 orig = texture(tex, v_texcoord);
if(wl_output != 0) { fragColor = orig; return; }
vec2 fc = gl_FragCoord.xy;
bool even = mod(fc.x + fc.y + float(0),2.0)==0.0;
vec4 pixel = even ? orig : vec4(0.0,0.0,0.0,1.0);
fragColor = pixel;
}
and then after allowing hypridle on-timeout = hyproled to activate:
cat /dev/shm/hyproled_shader.glsl
#version 300 es
precision highp float;
in vec2 v_texcoord;
uniform sampler2D tex;
uniform int wl_output;
layout(location = 0) out vec4 fragColor;
void main(){
vec4 orig = texture(tex, v_texcoord);
if(wl_output != 0) { fragColor = orig; return; }
vec2 fc = gl_FragCoord.xy;
bool even = mod(fc.x + fc.y + float(0),2.0)==0.0;
vec4 pixel = even ? orig : vec4(0.0,0.0,0.0,1.0);
fragColor = pixel;
}
vec4 pixel = even ? orig : vec4(0.0,0.0,0.0,1.0);
fragColor = pixel;
}
and also
cat /dev/shm/hyproled_shader.glsl
#version 300 es
precision highp float;
in vec2 v_texcoord;
uniform sampler2D tex;
uniform int wl_output;
layout(location = 0) out vec4 fragColor;
void main(){
vec4 orig = texture(tex, v_texcoord);
if(wl_output != 0) { fragColor = orig; return; }
vec2 fc = gl_FragCoord.xy;
bool even = mod(fc.x + fc.y + float(0),2.0)==0.0;
vec4 pixel = even ? orig : vec4(0.0,0.0,0.0,1.0);
vec4 pixel = even ? orig : vec4(0.0,0.0,0.0,1.0);
fragColor = pixel;
}
fragColor = pixel;
}
and also
cat /dev/shm/hyproled_shader.glsl
#version 300 es
precision highp float;
in vec2 v_texcoord;
uniform sampler2D tex;
uniform int wl_output;
layout(location = 0) out vec4 fragColor;
void main(){
vec4 orig = texture(tex, v_texcoord);
if(wl_output != 0) { fragColor = orig; return; }
vec2 fc = gl_FragCoord.xy;
bool even = mod(fc.x + fc.y + float(0),2.0)==0.0;
vec4 pixel = even ? orig : vec4(0.0,0.0,0.0,1.0);
vec4 pixel = even ? orig : vec4(0.0,0.0,0.0,1.0);
fragColor = pixel;
fragColor = pixel;
}
}
please try the latest version and report if the bug was fixed. thank you!
Well I managed to fix by making the whole hyproled write a single write. Seems to solve the issue. I do not understand what is causing hypridle to double-write the last few lines, maybe it is somehow executing the command twice, causing both the > to overwrite the file, then the two sets of >> to append and then it looks strange like shown above, No idea how that is happening though. Might be something to research since it might come into play in the future? But I did some research and came up blank, so who knows.
Here is the PR, definitely double check over it and make sure it functions, thanks!
https://github.com/mklan/hyproled/pull/11
Thanks for the investigation. I cannot reproduce the error so I don't want to make drastic changes, but seems like your system might run two instances of hypridle. Anyway please try this version, where I took your approach.
https://raw.githubusercontent.com/mklan/hyproled/refs/heads/ISSUE-9_fix-race-condition/hyproled
I reviewed your pr and it adds overall great value to the script even if I cannot reproduce your error. So if this fixes your issue I will merge your PR in.
I reviewed your pr and it adds overall great value to the script even if I cannot reproduce your error. So if this fixes your issue I will merge your PR in.
Sorry for the delay! But yes, I just tried it today and it retains functionality and works with hypridle for me as well! Thanks for cleaning my modifications up, glad we were able to improve it :)