{ config, pkgs, lib, ... }: let username = config.defaultUser or "henrov"; homeDir = "/home/${username}"; wallpaperDir = "${homeDir}/Wallpapers"; scriptDest = "${homeDir}/Wallpapers/wallpaper-sync-and-set.sh"; in { ############################ # Systemwide packages ############################ environment.systemPackages = with pkgs; [ swww waypaper jq rsync ]; ############################ # Install the script ############################ home.file."Wallpapers/wallpaper-sync-and-set.sh".source = ./assets/Wallpapers/wallpaper-sync-and-set.sh; home.file."Wallpapers/wallpaper-sync-and-set.sh".executable = true; ############################ # Systemd user service + timer ############################ systemd.user.services.wallpaperSync = { description = "2-way sync wallpapers + set random per workspace"; serviceConfig.Type = "oneshot"; serviceConfig.ExecStart = "${scriptDest}"; serviceConfig.Restart = "on-failure"; }; systemd.user.timers.wallpaperSyncTimer = { description = "Run wallpaper sync every hour"; wantedBy = [ "timers.target" ]; timerConfig.OnCalendar = "hourly"; timerConfig.Persistent = true; }; ############################ # Run at login ############################ systemd.user.services.wallpaperSyncLogin = { description = "Run wallpaper sync at login"; serviceConfig.Type = "oneshot"; serviceConfig.ExecStart = "${scriptDest}"; install.WantedBy = [ "default.target" ]; }; }