{ 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" ]; }; }; }