Files
nix/hosts/common/configs/user/gui/swww/default.nix
Nikolaos Karaolidis 1c554f1700 Update theme engine
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
2025-05-20 09:07:45 +01:00

78 lines
1.8 KiB
Nix

{
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 = ''
if [[ -L "${hmConfig.theme.configDir}"/wallpaper ]]; then
exec swww img "${hmConfig.theme.configDir}"/wallpaper
elif [[ -f "${hmConfig.theme.configDir}"/color ]]; then
exec swww clear "$(<"${hmConfig.theme.configDir}"/color)"
fi
'';
}
);
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.reloadExtraConfig = "${themeSwww} &";
wayland.windowManager.hyprland.onMonitorChange.services = [ "swww.service" ];
};
}