{ lib, config, pkgs, ... }: let cfg = config.marleyos.services.swaybg; in { options.marleyos.services.swaybg.enable = lib.mkEnableOption "swaybg"; config = lib.mkIf cfg.enable { home.packages = with pkgs; [ swaybg ]; systemd.user.services.swaybg = { Install = { WantedBy = ["xdg-desktop-autostart.target"]; }; Unit = { Description = "Wallpaper tool for Wayland compositors"; Documentation = ["man:swaybg(1)"]; After = ["graphical-session.target"]; PartOf = ["xdg-desktop-autostart.target"]; }; Service = { Type = "exec"; ExecStart = "${lib.getExe pkgs.swaybg} -i ${config.stylix.image}"; ExecReload = "${lib.getExe' pkgs.coreutils "kill"} -SIGUSR2 $MAINPID"; KillMode = "mixed"; Restart = "on-failure"; RestartSec = "1s"; RestartMaxDelaySec = "30s"; RestartSteps = 10; }; }; }; }