diff --git a/modules/lib/maintainers.nix b/modules/lib/maintainers.nix index 5286334e..de25f70c 100644 --- a/modules/lib/maintainers.nix +++ b/modules/lib/maintainers.nix @@ -19,6 +19,12 @@ githubId = 56743515; name = "Morgane Austreelis"; }; + Avimitin = { + name = "Avimitin"; + email = "dev@avimit.in"; + github = "Avimitin"; + githubId = 30021675; + }; blmhemu = { name = "blmhemu"; email = "19410501+blmhemu@users.noreply.github.com"; diff --git a/modules/misc/news.nix b/modules/misc/news.nix index cd0e7ffd..b7395a79 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1244,6 +1244,13 @@ in A new module is available: 'programs.awscli'. ''; } + + { + time = "2023-10-01T07:23:26+00:00"; + message = '' + A new module is available: 'programs.wpaperd'. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 889f486f..07c9f352 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -224,6 +224,7 @@ let ./programs/wezterm.nix ./programs/wlogout.nix ./programs/wofi.nix + ./programs/wpaperd.nix ./programs/xmobar.nix ./programs/xplr.nix ./programs/yazi.nix diff --git a/modules/programs/wpaperd.nix b/modules/programs/wpaperd.nix new file mode 100644 index 00000000..655024a0 --- /dev/null +++ b/modules/programs/wpaperd.nix @@ -0,0 +1,49 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.programs.wpaperd; + tomlFormat = pkgs.formats.toml { }; +in { + meta.maintainers = [ hm.maintainers.Avimitin ]; + + options.programs.wpaperd = { + enable = mkEnableOption "wpaperd"; + + package = mkPackageOption pkgs "wpaperd" { }; + + settings = mkOption { + type = tomlFormat.type; + default = { }; + example = literalExpression '' + { + eDP-1 = { + path = "/home/foo/Pictures/Wallpaper"; + apply-shadow = true; + }; + DP-2 = { + path = "/home/foo/Pictures/Anime"; + sorting = "descending"; + }; + } + ''; + description = '' + Configuration written to + {file}`$XDG_CONFIG_HOME/wpaperd/wallpaper.toml`. + See + for the full list of options. + ''; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ cfg.package ]; + + xdg.configFile = { + "wpaperd/wallpaper.toml" = mkIf (cfg.settings != { }) { + source = tomlFormat.generate "wpaperd-wallpaper" cfg.settings; + }; + }; + }; +} diff --git a/tests/default.nix b/tests/default.nix index 202a0143..d82953d8 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -196,6 +196,7 @@ import nmt { ./modules/programs/waybar ./modules/programs/wlogout ./modules/programs/wofi + ./modules/programs/wpaperd ./modules/programs/xmobar ./modules/programs/yt-dlp ./modules/services/avizo diff --git a/tests/modules/programs/wpaperd/default.nix b/tests/modules/programs/wpaperd/default.nix new file mode 100644 index 00000000..dfd4b041 --- /dev/null +++ b/tests/modules/programs/wpaperd/default.nix @@ -0,0 +1 @@ +{ wpaperd-example-settings = ./wpaperd-example-settings.nix; } diff --git a/tests/modules/programs/wpaperd/wpaperd-example-settings.nix b/tests/modules/programs/wpaperd/wpaperd-example-settings.nix new file mode 100644 index 00000000..8869f68c --- /dev/null +++ b/tests/modules/programs/wpaperd/wpaperd-example-settings.nix @@ -0,0 +1,26 @@ +{ ... }: + +{ + config = { + programs.wpaperd = { + enable = true; + settings = { + eDP-1 = { + path = "/home/foo/Pictures/Wallpaper"; + apply-shadow = true; + }; + DP-2 = { + path = "/home/foo/Pictures/Anime"; + sorting = "descending"; + }; + }; + }; + + test.stubs.wpaperd = { }; + + nmt.script = '' + assertFileContent home-files/.config/wpaperd/wallpaper.toml \ + ${./wpaperd-expected-settings.toml} + ''; + }; +} diff --git a/tests/modules/programs/wpaperd/wpaperd-expected-settings.toml b/tests/modules/programs/wpaperd/wpaperd-expected-settings.toml new file mode 100644 index 00000000..55c87b58 --- /dev/null +++ b/tests/modules/programs/wpaperd/wpaperd-expected-settings.toml @@ -0,0 +1,7 @@ +[DP-2] +path = "/home/foo/Pictures/Anime" +sorting = "descending" + +[eDP-1] +apply-shadow = true +path = "/home/foo/Pictures/Wallpaper"