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