From 209a24dff2b1098f24013cb4877d86cd0ae67c21 Mon Sep 17 00:00:00 2001 From: Avimitin Date: Thu, 28 Sep 2023 10:47:55 +0800 Subject: [PATCH] wpaperd: add wpaperd configuration Signed-off-by: Avimitin --- modules/lib/maintainers.nix | 6 +++ modules/misc/news.nix | 7 +++ modules/modules.nix | 1 + modules/programs/wpaperd.nix | 49 +++++++++++++++++++ tests/default.nix | 1 + tests/modules/programs/wpaperd/default.nix | 1 + .../wpaperd/wpaperd-example-settings.nix | 26 ++++++++++ .../wpaperd/wpaperd-expected-settings.toml | 7 +++ 8 files changed, 98 insertions(+) create mode 100644 modules/programs/wpaperd.nix create mode 100644 tests/modules/programs/wpaperd/default.nix create mode 100644 tests/modules/programs/wpaperd/wpaperd-example-settings.nix create mode 100644 tests/modules/programs/wpaperd/wpaperd-expected-settings.toml diff --git a/modules/lib/maintainers.nix b/modules/lib/maintainers.nix index 5286334e8..de25f70c1 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 cd0e7ffd6..b7395a794 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 889f486fc..07c9f3520 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 000000000..655024a06 --- /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 202a0143b..d82953d88 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 000000000..dfd4b041d --- /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 000000000..8869f68cc --- /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 000000000..55c87b58a --- /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"