105 lines
2.6 KiB
Nix
105 lines
2.6 KiB
Nix
{
|
|
pkgs,
|
|
config,
|
|
lib,
|
|
...
|
|
}:
|
|
with lib; let
|
|
cfg = config.programs.hyprpaper;
|
|
in {
|
|
options = {
|
|
programs.hyprpaper = {
|
|
enable = mkEnableOption "Hyprpaper - Wayland wallpaper utility";
|
|
|
|
systemd = {
|
|
enable = mkEnableOption "autostart service for Hyprpaper";
|
|
|
|
target = mkOption {
|
|
type = types.str;
|
|
default = "graphical-session.target";
|
|
example = "hyprland-session.target";
|
|
description = ''
|
|
The systemd target that will automatically start the Hyprpaper service.
|
|
'';
|
|
};
|
|
};
|
|
|
|
settings = with types; {
|
|
preload = mkOption {
|
|
type = listOf path;
|
|
default = [];
|
|
description = ''
|
|
Wallpaper images that should be preloaded into memory
|
|
'';
|
|
example = [./wallpapers/tensura.png];
|
|
};
|
|
|
|
wallpapers = mkOption {
|
|
type = attrsOf str;
|
|
default = {};
|
|
example = {"DP-1" = ./wallpapers/tensura.png;};
|
|
description = ''
|
|
Wallpaper to monitor mapper
|
|
'';
|
|
};
|
|
|
|
extraConfig = mkOption {
|
|
type = str;
|
|
default = "";
|
|
description = "Check https://github.com/hyprwm/hyprpaper#usage for info";
|
|
example = ''
|
|
newConfigOption = foo,bar
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
config = {
|
|
home.packages = mkIf cfg.enable [pkgs.hyprpaper];
|
|
|
|
systemd.user.services.hyprpaper = mkIf cfg.systemd.enable {
|
|
Unit = {
|
|
Description = "autostart service for Hyprpaper";
|
|
Documentation = "https://github.com/hyprwm/hyprpaper";
|
|
BindsTo = ["graphical-session.target"];
|
|
After = ["graphical-session-pre.target"];
|
|
};
|
|
|
|
Service = {
|
|
ExecStart = "${pkgs.hyprpaper}/bin/hyprpaper";
|
|
ExecReload = "${pkgs.coreutils}/bin/kill -SIGUSR2 $MAINPID";
|
|
Restart = "on-failure";
|
|
KillMode = "mixed";
|
|
};
|
|
|
|
Install = {WantedBy = [cfg.systemd.target];};
|
|
};
|
|
|
|
xdg.configFile = mkIf cfg.enable {
|
|
"hypr/hyprpaper.conf".text = ''
|
|
# Auto-generated by Nix home-manager module
|
|
|
|
# hyprpaper.settings.preload
|
|
${(lists.foldl (acc: v:
|
|
acc
|
|
+ ''
|
|
preload = ${v}
|
|
'') ""
|
|
cfg.settings.preload)}
|
|
|
|
# hyprpaper.settings.wallpapers
|
|
${(lists.foldl (acc: v:
|
|
acc
|
|
+ ''
|
|
wallpaper = ${v}
|
|
'') "" (pkgs.lib.attrsets.mapAttrsToList (name: val: name + "," + val)
|
|
cfg.settings.wallpapers))}
|
|
|
|
# hyprpaper.settings.extraConfig
|
|
${cfg.settings.extraConfig}
|
|
'';
|
|
};
|
|
};
|
|
}
|