{ 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))) ) ); wallpaperConfig = { options = { name = mkOption { description = "The base filename of the image, without size and extension."; type = types.str; }; sizes = mkOption { description = "The sizes this wallpaper comes in, as specified in the filename."; type = with types; listOf int; }; extension = mkOption { description = "The extension of the wallpaper"; type = types.enum [ "jpg" "png" "gif" ]; }; }; }; 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 = "Images to make available as wallpaper. The files should be named as `-.` and be placed in the `wallpapers` subdirectory"; type = with types; listOf (submodule wallpaperConfig); }; }; config = mkIf cfg.enable { home.packages = [ pkgs.nitrogen ]; xsession.windowManager.i3.config.startup = [ { command = toString i3SetWallpaper; notification = false; } ]; }; }