Files
nix/hosts/common/user/configs/gui/swww/default.nix
2024-07-16 17:46:58 +03:00

66 lines
1.5 KiB
Nix

{
username ? throw "username argument is required",
}:
{
config,
lib,
pkgs,
...
}:
let
userConfig = config.users.users.${username};
hmConfig = config.home-manager.users.${username};
themeSwww = lib.meta.getExe (
pkgs.writeShellApplication {
name = "theme-swww";
runtimeInputs = with pkgs; [
coreutils
swww
];
text = "exec swww img \"${hmConfig.theme.configDir}/wallpaper\"";
}
);
in
{
home-manager.users.${username} = {
home = {
packages = with pkgs; [ swww ];
persistence."/cache${userConfig.home}".directories = [ "${hmConfig.xdg.relativeCacheHome}/swww" ];
};
systemd.user.services.swww = {
Unit = {
Description = "Wallpaper daemon";
BindsTo = [ "graphical-session.target" ];
After = [ "graphical-session.target" ];
};
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} &";
};
}