{ pkgs, ... }: { systemd.user.services.wallpaper-changer = { Unit = { Description = "Script to change wallpaper using swww"; PartOf = [ "hyprland-session.target" ]; After = [ "hyprland-session.target" ]; # or "wayland.target", depending on your system setup }; Install = { WantedBy = [ "default.target" ]; }; Service = { Type = [ "oneshot" ]; ExecStart = "${pkgs.writeShellScript "swww-wallpaper-changer" '' export WAYLAND_DISPLAY="wayland-1" wallpaper_dir="$HOME/.local/share/bg/" # Allow some time for desktop to start sleep 3 echo "starting daemon..." ${pkgs.swww}/bin/swww-daemon & while true; do find "$wallpaper_dir" -type f -follow \( -iname \*.jpg -o -iname \*.png -o -iname \*.gif -o -iname \*.bmp \) | shuf | while read -r file; do ${pkgs.swww}/bin/swww img "$file" --transition-step 10 --transition-fps 60 [ $? != 0 ] && echo "swww failed, reloading daemon" && exit 1 sleep 600 done done ''}"; }; }; }