2024-02-05 11:46:52 +01:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
2022-11-11 11:54:21 +01:00
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.eboskma.wallpapers;
|
|
|
|
|
2024-02-05 11:46:52 +01:00
|
|
|
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" (
|
2024-04-16 19:32:32 +02:00
|
|
|
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)))
|
2024-02-05 11:46:52 +01:00
|
|
|
)
|
|
|
|
);
|
2023-09-29 11:52:45 +02:00
|
|
|
|
|
|
|
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";
|
2024-02-05 11:46:52 +01:00
|
|
|
type = types.enum [
|
|
|
|
"jpg"
|
|
|
|
"png"
|
|
|
|
"gif"
|
|
|
|
];
|
2023-09-29 11:52:45 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2022-11-11 11:54:21 +01:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options.eboskma.wallpapers = {
|
|
|
|
enable = mkEnableOption "wallpapers";
|
|
|
|
backgroundColor = mkOption {
|
|
|
|
description = "Hex value of the background color";
|
2022-11-19 20:00:54 +01:00
|
|
|
type = types.strMatching "#[[:xdigit:]]{6}";
|
2022-11-11 11:54:21 +01:00
|
|
|
default = "#000000";
|
|
|
|
example = "#ff0000";
|
|
|
|
};
|
|
|
|
images = mkOption {
|
2023-09-29 11:52:45 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|