{ config, lib, pkgs, ... }: let inherit (lib) getExe getExe' mkOption types; in { options.custom.backgroundDir = mkOption { default = config.home.homeDirectory + "/Pictures/Backgrounds"; type = with types; uniq str; }; config = { services.swww.enable = true; systemd.user = { services.swww-randomize = { Unit = { Description = "randomly change the swww background image"; Requires = "swww.service"; }; Service = { Type = "oneshot"; ExecStart = "${getExe pkgs.bash} -c '${getExe pkgs.findutils} ${config.custom.backgroundDir} -type f | ${getExe' pkgs.coreutils "shuf"} -n 1 | ${getExe' pkgs.findutils "xargs"} ${getExe pkgs.swww} img --transition-step 16'"; }; Install.WantedBy = [ "default.target" ]; }; timers.swww-randomize = { Unit.Description = "randomly changes the swww background image"; Timer = { Unit = "swww-random"; OnCalendar = "*-*-* *:00,30:00"; }; Install.WantedBy = [ "timers.target" ]; }; }; }; }