Skip to content

Commit c7c6bc9

Browse files
committed
Allow setting different wallpapers for different desktops
1 parent 5eeb017 commit c7c6bc9

File tree

1 file changed

+37
-27
lines changed

1 file changed

+37
-27
lines changed

modules/workspace.nix

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ in
161161
};
162162

163163
wallpaper = lib.mkOption {
164-
type = with lib.types; nullOr path;
164+
type = with lib.types; nullOr (either path (listOf path));
165165
default = null;
166166
example = lib.literalExpression ''"''${pkgs.kdePackages.plasma-workspace-wallpapers}/share/wallpapers/Kay/contents/images/1080x1920.png"'';
167167
description = ''
@@ -453,34 +453,44 @@ in
453453
for (const desktop of allDesktops) {
454454
desktop.wallpaperPlugin = "org.kde.image";
455455
desktop.currentConfigGroup = ["Wallpaper", "org.kde.image", "General"];
456-
desktop.writeConfig("Image", "file://${toString cfg.workspace.wallpaper}");
457456
${
458-
lib.optionalString (cfg.workspace.wallpaperFillMode != null)
459-
''desktop.writeConfig("FillMode", "${
460-
toString wallpaperFillModeTypes.${cfg.workspace.wallpaperFillMode}
461-
}");''
457+
if (builtins.typeOf cfg.workspace.wallpaper) == "list" then
458+
''
459+
let images = [
460+
${
461+
builtins.concatStringsSep "\n," (map (
462+
wallpaper: ''"file://${toString wallpaper}"''
463+
) cfg.workspace.wallpaper)
464+
}
465+
];
466+
let image = images[desktop.screen];''
467+
else
468+
''let image = "file://${toString cfg.workspace.wallpaper}""''
462469
}
463-
${
464-
lib.optionalString (cfg.workspace.wallpaperBackground != null)
465-
''desktop.writeConfig("${
466-
if cfg.workspace.wallpaperBackground ? blur && cfg.workspace.wallpaperBackground.blur != null then
467-
"Blur"
468-
else if
469-
cfg.workspace.wallpaperBackground ? color && cfg.workspace.wallpaperBackground.color != null
470-
then
471-
"Color"
472-
else
473-
throw "plasma-manager: wallpaperBackground is not null and has no option set"
474-
}", "${
475-
if cfg.workspace.wallpaperBackground ? blur && cfg.workspace.wallpaperBackground.blur != null then
476-
lib.boolToString cfg.workspace.wallpaperBackground.blur
477-
else if
478-
cfg.workspace.wallpaperBackground ? color && cfg.workspace.wallpaperBackground.color != null
479-
then
480-
cfg.workspace.wallpaperBackground.color
481-
else
482-
throw "plasma-manager: wallpaperBackground is not null and has no option set"
483-
}");''
470+
if (image) {
471+
desktop.writeConfig("Image", image);
472+
${
473+
lib.optionalString (cfg.workspace.wallpaperBackground != null)
474+
''desktop.writeConfig("${
475+
if cfg.workspace.wallpaperBackground ? blur && cfg.workspace.wallpaperBackground.blur != null then
476+
"Blur"
477+
else if
478+
cfg.workspace.wallpaperBackground ? color && cfg.workspace.wallpaperBackground.color != null
479+
then
480+
"Color"
481+
else
482+
throw "plasma-manager: wallpaperBackground is not null and has no option set"
483+
}", "${
484+
if cfg.workspace.wallpaperBackground ? blur && cfg.workspace.wallpaperBackground.blur != null then
485+
lib.boolToString cfg.workspace.wallpaperBackground.blur
486+
else if
487+
cfg.workspace.wallpaperBackground ? color && cfg.workspace.wallpaperBackground.color != null
488+
then
489+
cfg.workspace.wallpaperBackground.color
490+
else
491+
throw "plasma-manager: wallpaperBackground is not null and has no option set"
492+
}");''
493+
}
484494
}
485495
}
486496
'';

0 commit comments

Comments
 (0)