nixos-config/home-manager/modules/wallpapers/default.nix

63 lines
1.8 KiB
Nix
Raw Normal View History

2022-11-11 11:54:21 +01:00
{ 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" ];
};
};
};
2022-11-11 11:54:21 +01:00
in
{
options.eboskma.wallpapers = {
enable = mkEnableOption "wallpapers";
backgroundColor = mkOption {
description = "Hex value of the background color";
type = types.strMatching "#[[:xdigit:]]{6}";
2022-11-11 11:54:21 +01:00
default = "#000000";
example = "#ff0000";
};
images = mkOption {
description = "Images to make available as wallpaper. The files should be named as `<name>-<size>.<ext>` and be placed in the `wallpapers` subdirectory";
type = with types; listOf (submodule wallpaperConfig);
2022-11-11 11:54:21 +01:00
};
};
config = mkIf cfg.enable {
home.packages = [ pkgs.nitrogen ];
xsession.windowManager.i3.config.startup = [
{
command = toString i3SetWallpaper;
notification = false;
}
];
};
}