{ config, pkgs, flakeRoot, ... }: let homeDir = "/home/${config.users.users."traveldroid".name or "traveldroid"}"; scriptFile = "${homeDir}/Wallpapers/script/set-wallpapers-at-logon.sh"; in { ############################ # System-wide packages ############################ environment.systemPackages = with pkgs; [ swww waypaper jq rsync ]; ############################ # User service: run the script ############################ systemd.user.services.wallpaperSync = { description = "Run set-wallpapers-at-logon.sh"; serviceConfig.Type = "oneshot"; serviceConfig.ExecStart = scriptFile; serviceConfig.Restart = "on-failure"; }; ############################ # Timer: run service every 15 minutes ############################ systemd.user.timers.wallpaperSyncTimer = { description = "Run wallpaperSync service every 15 minutes"; wantedBy = [ "timers.target" ]; timerConfig.OnUnitActiveSec = "15min"; timerConfig.Persistent = true; }; ############################ # Ensure the script runs at login ############################ systemd.user.services.wallpaperSyncLogin = { description = "Run wallpaperSync at login"; wantedBy = [ "default.target" ]; serviceConfig.Type = "oneshot"; serviceConfig.ExecStart = scriptFile; }; }