Tsting systemd timers and services instead of cron

This commit is contained in:
iFargle 2024-01-02 22:02:53 +09:00
parent 453383440d
commit aa02d6ce2d

View file

@ -35,18 +35,42 @@
tailscale-systray tailscale-systray
]; ];
# Schedule cronjobs for changing the theme systemd.services = {
services.cron = { "get-theme-times" = {
enable = true; enable = true;
systemCronJobs = [ path = [ pkgs.curl ];
# Set the 'at' jobs for changing the theme script = "curl wttr.in > /tmp/wttr.in";
''0 12 * * * albert curl -s wttr.in?format=j1 > /tmp/wttr.in'' after = [ "networking-online.target" ];
''0 * * * * albert sleep 10; echo "plasma-apply-colorscheme -platform offscreen Arc" | at `fx /tmp/wttr.in .weather[0].astronomy[0].sunrise`'' serviceConfig.Type = "oneshot";
''0 * * * * albert sleep 10; echo "plasma-apply-colorscheme -platform offscreen ArcDark" | at `fx /tmp/wttr.in .weather[0].astronomy[0].sunset` '' onSucces = [
# At reboot as well "light-theme.service"
''@reboot albert curl -s wttr.in?format=j1 > /tmp/wttr.in'' "dark-theme.service"
''@reboot albert sleep 10; echo "plasma-apply-colorscheme -platform offscreen Arc" | at `fx /tmp/wttr.in .weather[0].astronomy[0].sunrise`'' ];
''@reboot albert sleep 10; echo "plasma-apply-colorscheme -platform offscreen ArcDark" | at `fx /tmp/wttr.in .weather[0].astronomy[0].sunset` '' };
]; light-theme = {
enable = true;
path = [ pkgs.at pkgs.fx];
script = ''echo "plasma-apply-colorscheme -platform offscreen Arc" | at `fx /tmp/wttr.in .weather[0].astronomy[0].sunrise`'';
serviceConfig.Type = "oneshot";
};
dark-theme = {
enable = true;
path = [ pkgs.at pkgs.fx];
script = ''echo "plasma-apply-colorscheme -platform offscreen ArcDark" | at `fx /tmp/wttr.in .weather[0].astronomy[0].sunset`'';
serviceConfig.Type = "oneshot";
};
};
systemd.timers = {
"light-theme" = {
enable = true;
partOf = [ "light-theme.service" ];
timerConfig.OnCalendar = [ "*-*-* *:*:00" ];
};
"dark-theme" = {
enable = true;
partOf = [ "dark-theme.service" ];
timerConfig.OnCalendar = [ "*-*-* *:*:00" ];
};
}; };
} }