{ user ? throw "user argument is required", home ? throw "home argument is required", }: { config, lib, utils, pkgs, ... }: let hmConfig = config.home-manager.users.${user}; themeSwww = lib.meta.getExe ( pkgs.writeShellApplication { name = "theme-swww"; runtimeInputs = with pkgs; [ coreutils swww ]; text = "exec swww img \"${hmConfig.theme.configDir}/wallpaper\""; } ); in { environment.persistence."/cache"."${home}/.cache/swww" = { }; home-manager.users.${user} = { home.packages = with pkgs; [ swww ]; systemd.user.services.swww = { Unit = { Description = "Wallpaper daemon"; BindsTo = [ "graphical-session.target" ]; After = [ "graphical-session.target" config.environment.persistence."/cache"."${home}/.cache/swww".mount ]; }; Service = { Type = "forking"; ExecStart = lib.meta.getExe ( pkgs.writeShellApplication { name = "init-swww"; runtimeInputs = with pkgs; [ swww ]; text = "exec swww init"; } ); ExecStartPost = themeSwww; ExecStop = lib.meta.getExe ( pkgs.writeShellApplication { name = "kill-swww"; runtimeInputs = with pkgs; [ swww ]; text = "exec swww kill"; } ); }; Install.WantedBy = [ "graphical-session.target" ]; }; theme.extraConfig = lib.mkAfter "${themeSwww} &"; }; }