diff options
| author | Miran Bastaja <miran.bastaja04@gmail.com> | 2023-11-03 15:59:16 +0100 |
|---|---|---|
| committer | Miran Bastaja <miran.bastaja04@gmail.com> | 2023-11-03 15:59:16 +0100 |
| commit | f559671cae7b02526dedf7923b135c09e0d095d5 (patch) | |
| tree | 0f273fb13211c4aa7cae2add41e3aa2b1c6d7785 /share/hm-modules/wpaperd.nix | |
Inital commit ;P
Diffstat (limited to 'share/hm-modules/wpaperd.nix')
| -rw-r--r-- | share/hm-modules/wpaperd.nix | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/share/hm-modules/wpaperd.nix b/share/hm-modules/wpaperd.nix new file mode 100644 index 0000000..c38da21 --- /dev/null +++ b/share/hm-modules/wpaperd.nix @@ -0,0 +1,74 @@ +{ config, lib, pkgs, ... }: +with lib; +let + cfg = config.services.wpaperd; + tomlFormat = pkgs.formats.toml { }; +in +{ + options.services.wpaperd = { + enable = mkEnableOption "enable wpaperd"; + + package = mkOption { + default = pkgs.wpaperd; + defaultText = literalExpression "pkgs.wpaperd"; + type = types.package; + example = literalExpression "pkgs.wpaperd"; + description = "The package to use for the wpaperd binary."; + }; + + settings = mkOption { + type = tomlFormat.type; + description = '' + Configuration for wpaperd. Options are specified on: + https://github.com/danyspin97/wpaperd#wallpaper-configuration + ''; + example = literalExpression '' + { + default = { + path = "/home/myusername/Pictures/Wallpapers/"; + duration = "10m" + sorting = "random"; + }; + } + ''; + }; + + systemdTarget = mkOption { + type = types.str; + default = "hyprland-session.target"; + description = '' + Systemd target to bind to. + Note: if you're using home-manager to configure hyprland, you want to + have `wayland.windowManager.hyprland.systemdIntegration` enabled. + ''; + }; + }; + + config = mkIf cfg.enable { + assertions = [ + (hm.assertions.assertPlatform "services.wpaperd" pkgs platforms.linux) + ]; + + home.packages = [ cfg.package ]; + + xdg.configFile = { + "wpaperd/wallpaper.toml" = mkIf (cfg.settings != { }) { + source = tomlFormat.generate "wpaperd-config" cfg.settings; + }; + }; + + systemd.user.services.wpaperd = { + Unit = { + Description = "Wallpaper daemon for Wayland"; + BindsTo = [ cfg.systemdTarget ]; + }; + + Service = { + Type = "simple"; + ExecStart = "${cfg.package}/bin/wpaperd --no-daemon"; + }; + + Install.WantedBy = [ cfg.systemdTarget ]; + }; + }; +} |
