{ config, pkgs, lib, flakeRoot, ... }: let username = config.defaultUser or "henrov"; homeDir = "/home/${username}"; wallpaperDst = "${homeDir}/Wallpapers"; wallpaperSrc = "${flakeRoot}/assets/traveldroid/Wallpapers"; in { ############################ # Packages ############################ environment.systemPackages = with pkgs; [ swww waypaper jq rsync ]; ############################ # Service (does the work) ############################ systemd.user.services.wallpaperUpdater = { description = "Sync wallpapers and apply them"; after = [ "default.target" ]; serviceConfig = { Type = "oneshot"; ExecStart = '' # Create destination folder mkdir -p ${wallpaperDst} # Copy FULL folder contents (mirror) rsync -a --delete ${wallpaperSrc}/ ${wallpaperDst}/ # Ensure script is executable chmod +x ${wallpaperDst}/set-wallpapers-per-workspace.sh # Run script ${wallpaperDst}/set-wallpapers-per-workspace.sh ''; }; }; ############################ # Timer (runs every 15 min) ############################ systemd.user.timers.wallpaperUpdater = { description = "Run wallpaper updater every 15 minutes"; wantedBy = [ "timers.target" ]; timerConfig = { OnBootSec = "2min"; # run shortly after login OnUnitActiveSec = "15min"; # repeat every 15 min Persistent = true; }; }; }