loqusion / hyprshade

Hyprland shader configuration tool
MIT License
222 stars 7 forks source link

systemd timer need an additional rule 'AccuracySec=1ms' #17

Closed vincentaxhe closed 3 months ago

vincentaxhe commented 6 months ago

systemd tend to excute on some random secs to avoid cpu request peak.But hyprshade need to run exactly at starttime. In install.py,

[Timer]
AccuracySec=1ms
{timer_config}

I found hyprshade failed to run ,or maybe it run before some secs leads to shade change didnot apply.So I add the rule in hyprshade.timer, have not test it.

loqusion commented 6 months ago

That's interesting, thank you for making me aware of this issue and providing a potential solution.

Setting AccuracySec to 1ms on its own would certainly be the easiest solution to implement, but I also don't want hyprshade to needlessly take priority over other processes when it can work just as well with an approximated schedule.

I think we could set AccuracySec to something like 1sec (as opposed to the 1min default) and adjust start_time and end_time by a constant value in order to relax the threshold in the following function:

https://github.com/loqusion/hyprshade/blob/0aada948ad5eca2962978afb22524b89d2728bf1/src/hyprshade/config/schedule.py#L50-L55

That way, when hyprshade auto is called by the systemd service, it doesn't matter if it happens a little bit before or after the scheduled time, the correct shader will still be activated regardless (assuming the user doesn't have shaders which activate 1 second apart from each other).

vincentaxhe commented 6 months ago

I found hyprshade.timer should not be blamed .because I run 'systemctl --user start hyprshade.service' ,it failed

hyprshade[221320]: Error: Command '['hyprctl', 'keyword', 'decoration:screen_shader', '/home/vincent/.config/hypr/shaders/gentle-blue-light-filter.glsl']' returned non-zero exit status 1.

there must be some 'Enivironment=' in service file need to set properly.

loqusion commented 6 months ago

510da6bc6221e0da100871447d4616292828eae1 has more descriptive error reporting for hyprctl; could you try it and see if that helps pinpoint the issue?

vincentaxhe commented 6 months ago

I test it with replaced git version python scripts.Run systemctl --user start hyprshade.service,the output is

Error: hyprctl returned a non-zero exit code. command:hyprctl keyword decoration:screen_shader /usr/share/hyprshade/shaders/vibrance.glsl stdout:HYPRLAND_INSTANCE_SIGNATURE not set! (is hyprland running?) stderr:

that's obvious.I get it from /proc/pid/environment like 'HYPRLAND_INSTANCE_SIGNATURE=5f8e4068e51480791dbccbe48e86910e9b3cc881_1704025082',how to set it as it seems changeable.

loqusion commented 6 months ago

I have the following lines in my hyprland.conf, perhaps this is how systemd --user acquires the HYPRLAND_INSTANCE_SIGNATURE:

exec-once = dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP
exec-once = systemctl --user import-environment

(Also see the hyprland faq)

vincentaxhe commented 6 months ago

It worked well. Could timer add a rule on condition only start timer on Hyprland session, though when not hyprland session it just failed ,no harm.

kaushalyap commented 4 months ago

@loqusion First of all thanks for Hyprshade, I was really missing night light mode in hyprland, you project seem to address it

While strictly not related to the issue, I have follow scheduling hyprdim instructions but dimming does not happen according to the schedule, here are somethings that I observed

May be following hints a bug

❯ hyprshade auto
Error: 'start_time'

It seem this happens when default = false in the vibrance shader. Is there way I could make Unfiltered my default shader instead of vibrance?

It seems instructions on the README is outdated?

❯ systemctl --user import-environment
Calling import-environment without a list of variable names is deprecated.
loqusion commented 4 months ago

@kaushalyap

[!NOTE] This information is outdated as of v4.0.0.

You don't have to do anything special to make "no shader" the default shader besides have no default shader.

5b4acd7e9ae1292c9b1ca805622c3d39c46e15df and 8c8601ccf441dbec0970bc9fe35d50fc424ea7bd implement clearer config validation, so now the error message will look like:

Error: Failed to parse /home/loqusion/.config/hypr/hyprshade.toml: Non-default shader 'vibrance' must define `start_time`

Any non-default shader will never activate on schedule without start_time, which is why this error is produced.

I've also updated the outdated README instructions.