Im running hyprsunset at 18:00 every day to “emulate” nightmode for my screen (lower color temp to 5000k). This is done with a systemd timer+service.
My timer right now is triggered as usual at 18 and runs hyprsunset fine.
But what happens if the timer is triggered at 18 but then i restart my system at 19?
I assume the service wont be started again?
How can i keep my service active but only between 18:00 and 08:00 the next day, even thru system restarts?
Or you use wlsunset which you just start as a service and does all that for you. You just give it your geo coordinates and based on the sunset at that location it successively changes the Gama for you. This works flawlessly on my setup.
systemd.user.timers."hyprsunset" = {
wantedBy = [ "timers.target" ];
timerConfig = {
OnCalendar = "18:00:00";
Unit = "hyprsunset.service";
};
};
systemd.user.services."hyprsunset" = {
wantedBy = [ "default.target" ];
script = ''
current_hour=$(date +"%H")
if [ "$current_hour" -ge 18 ] || [ "$current_hour" -lt 9 ]; then
echo "The current time is after 18:00. Starting hyprsunset!"
${unstable.hyprsunset}/bin/hyprsunset --temperature 5000
else
echo "The current time is not after 18:00. Not starting hyprsunset."
fi
'';
serviceConfig = {
Type = "oneshot";
};
};