{ pkgs, config, lib, ... }: with lib; let cfg = config.eboskma.wallpapers; i3SetWallpaper = pkgs.writeShellScript "i3-set-wallpaper" (if builtins.isPath cfg.images then ''${pkgs.nitrogen}/bin/nitrogen --set-color=${cfg.backgroundColor} --set-tiled ${cfg.images}'' else builtins.concatStringsSep "\n" (map ({ fst, snd }: let image = fst; monitor = toString snd; in ''${pkgs.nitrogen}/bin/nitrogen --head=${monitor} --set-color=${cfg.backgroundColor} --set-tiled ${image}'') (zipLists cfg.images (builtins.genList (x: x) (builtins.length cfg.images))))); in { options.eboskma.wallpapers = { enable = mkEnableOption "wallpapers"; backgroundColor = mkOption { description = "Hex value of the background color"; type = types.strMatching "#[[:xdigit:]]{6}"; default = "#000000"; example = "#ff0000"; }; images = mkOption { description = "Image(s) to use as wallpapers. For multiple monitors, either set a single image to use on all monitors, or set a list with as many images as monitors you have"; type = with types; oneOf [ path (nonEmptyListOf path) ]; }; }; config = mkIf cfg.enable { home.packages = [ pkgs.nitrogen ]; xsession.windowManager.i3.config.startup = [ { command = toString i3SetWallpaper; notification = false; } ]; }; }