Large module update

This commit is contained in:
Filippo Berto 2021-06-01 22:19:24 +02:00
parent 492ae9d92a
commit a61bfe3c50
18 changed files with 463 additions and 87 deletions

View file

@ -0,0 +1,45 @@
{ pkgs, config, ... }:
let
fehCmd = "${pkgs.feh}/bin/feh";
backgrounds_directory = ~/Immagini/Sfondi ;
update_time = 10;
in {
home.file.".local/bin/update_background.sh" = {
text = ''
#!${pkgs.bash}/bin/bash
image=`find ${backgrounds_directory} -type f | grep -v "/\." | shuf -n 1`
${fehCmd} --bg-fill --no-fehbg "$image"
'';
target = ".local/bin/update_background.sh";
executable = true;
};
systemd.user.services."update-background" = {
Unit = {
Description = "Update the desktop background";
After = [ "graphical-session.target" ];
PartOf = [ "graphical-session.target" ];
RequiresMountsFor = [ "/home/bertof/Immagini" ];
};
Install = {
WantedBy = [ "graphical-session.target" ];
};
Service = {
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" ];
};
};
}