{ config, lib, pkgs, ... }: { options.services.swww-randomize = { enable = lib.mkEnableOption "enable the randomization swww service"; backgroundDir = lib.mkOption { default = config.home.homeDirectory + "/Pictures/Backgrounds"; description = "directory with images to use for the background"; type = with lib.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 = "${lib.getExe pkgs.bash} -c '${lib.getExe pkgs.findutils} ${config.services.swww-randomize.backgroundDir} -type f | ${lib.getExe' pkgs.coreutils "shuf"} -n 1 | ${lib.getExe' pkgs.findutils "xargs"} ${lib.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-randomize"; OnCalendar = "*-*-* *:00,30:00"; }; Install.WantedBy = [ "timers.target" ]; }; }; }; }