Completed centralized update

This commit is contained in:
Filippo Berto 2021-06-14 07:01:37 +02:00
parent ef5b48d142
commit 83c9c72688
15 changed files with 328 additions and 138 deletions

View file

@ -1,9 +1,10 @@
{ pkgs, config, ... }:
let
fehCmd = "${pkgs.feh}/bin/feh";
backgrounds_directory = ~/Immagini/Sfondi ;
update_time = 10;
in {
backgrounds_directory = ~/Immagini/Sfondi;
update_time = "10m";
in
{
home.file.".local/bin/update_background.sh" = {
text = ''
#!${pkgs.bash}/bin/bash
@ -16,8 +17,8 @@ in {
systemd.user.services."update-background" = {
Unit = {
Description = "Update the desktop background";
After = [ "graphical-session.target" ];
Description = "Set random desktop background using feh";
After = [ "graphical-session.pre.target" ];
PartOf = [ "graphical-session.target" ];
RequiresMountsFor = [ "/home/bertof/Immagini" ];
};
@ -25,21 +26,15 @@ in {
WantedBy = [ "graphical-session.target" ];
};
Service = {
Type = "oneshot";
IOSchedulingClass = "idle";
ExecStart = "${config.home.homeDirectory}/${config.home.file.".local/bin/update_background.sh".target}";
};
};
systemd.user.timers."update-background" = {
Unit = {
Description="Run update-background every ${toString update_time} minutes";
PartOf = [ "graphical-session.target" ];
After = [ "graphical-session.target" ];
};
Timer = {
OnUnitActiveSec="${toString update_time}m";
};
Install = {
WantedBy = [ "graphical-session.target" ];
};
Unit = { Description = "Set random desktop background using feh"; };
Timer = { OnUnitActiveSec = update_time; };
Install = { WantedBy = [ "timers.target" ]; };
};
}