1
0
mirror of https://github.com/nix-community/home-manager synced 2024-06-01 04:23:34 +02:00
home-manager/modules/services/hyprpaper.nix
2024-05-01 08:07:37 -05:00

96 lines
2.5 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.hyprpaper;
in {
meta.maintainers = [ maintainers.khaneliman maintainers.fufexan ];
options.services.hyprpaper = {
enable = mkEnableOption "Hyprpaper, Hyprland's wallpaper daemon";
package = mkPackageOption pkgs "hyprpaper" { };
settings = lib.mkOption {
type = with lib.types;
let
valueType = nullOr (oneOf [
bool
int
float
str
path
(attrsOf valueType)
(listOf valueType)
]) // {
description = "Hyprpaper configuration value";
};
in valueType;
default = { };
description = ''
hyprpaper configuration written in Nix. Entries with the same key
should be written as lists. Variables' and colors' names should be
quoted. See <https://wiki.hyprland.org/Hypr-Ecosystem/hyprpaper/> for more examples.
'';
example = lib.literalExpression ''
{
general = {
after_sleep_cmd = "hyprctl dispatch dpms on";
ignore_dbus_inhibit = false;
lock_cmd = "hyprlock";
};
listener = [
{
timeout = 900;
on-timeout = "hyprlock";
}
{
timeout = 1200;
on-timeout = "hyprctl dispatch dpms off";
on-resume = "hyprctl dispatch dpms on";
}
];
}
'';
};
importantPrefixes = lib.mkOption {
type = with lib.types; listOf str;
default = [ "$" ];
example = [ "$" ];
description = ''
List of prefix of attributes to source at the top of the config.
'';
};
};
config = mkIf cfg.enable {
xdg.configFile."hypr/hyprpaper.conf" = mkIf (cfg.settings != { }) {
text = lib.hm.generators.toHyprconf {
attrs = cfg.settings;
inherit (cfg) importantPrefixes;
};
};
systemd.user.services.hyprpaper = {
Install = { WantedBy = [ "graphical-session.target" ]; };
Unit = {
ConditionEnvironment = "WAYLAND_DISPLAY";
Description = "hyprpaper";
After = [ "graphical-session-pre.target" ];
PartOf = [ "graphical-session.target" ];
X-Restart-Triggers =
[ "${config.xdg.configFile."hypr/hyprpaper.conf".source}" ];
};
Service = {
ExecStart = "${getExe cfg.package}";
Restart = "always";
RestartSec = "10";
};
};
};
}