Skip to content

Commit

Permalink
Merge branch 'trunk' into desktop-widgets-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
HeitorAugustoLN authored Aug 22, 2024
2 parents 73b3b88 + 0b7f9b5 commit 88433d5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
12 changes: 12 additions & 0 deletions lib/wallpapers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,16 @@
};
};
};

# Values are taken from
# https://invent.kde.org/plasma/kdeplasma-addons/-/blob/bc53d651cf60709396c9229f8c582ec8a9d2ee53/applets/mediaframe/package/contents/ui/ConfigGeneral.qml#L148-170
wallpaperFillModeTypes = {
"stretch" = 0; # a.k.a. Scaled
"preserveAspectFit" = 1; # a.k.a. Scaled Keep Proportions
"preserveAspectCrop" = 2; # a.k.a. Scaled And Cropped
"tile" = 3;
"tileVertically" = 4;
"tileHorizontally" = 5;
"pad" = 6; # a.k.a. Centered
};
}
3 changes: 3 additions & 0 deletions modules/panels.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
} @ args:
let
cfg = config.programs.plasma;
inherit (import ../lib/wallpapers.nix { inherit lib; }) wallpaperFillModeTypes;

desktopWidgets = if cfg.desktop.widgets != null then cfg.desktop.widgets else [];

Expand Down Expand Up @@ -216,6 +217,7 @@ in
"\"" + (builtins.toString path) + "\"" else
"[" + (builtins.concatStringsSep "," (map (s: "\"" + s + "\"") path)) + "]"});
desktop.writeConfig("SlideInterval", "${builtins.toString cfg.workspace.wallpaperSlideShow.interval}");
${lib.optionalString (cfg.workspace.wallpaperFillMode != null) ''desktop.writeConfig("FillMode", "${cfg.workspace.wallpaperFillMode}");''}
}
'' else "");
wallpaperPOTD = (if (cfg.workspace.wallpaperPictureOfTheDay != null) then ''
Expand All @@ -226,6 +228,7 @@ in
desktop.currentConfigGroup = ["Wallpaper", "org.kde.potd", "General"];
desktop.writeConfig("Provider", "${cfg.workspace.wallpaperPictureOfTheDay.provider}");
desktop.writeConfig("UpdateOverMeteredConnection", "${if (cfg.workspace.wallpaperPictureOfTheDay.updateOverMeteredConnection) then "1" else "0"}");
${lib.optionalString (cfg.workspace.wallpaperFillMode != null) ''desktop.writeConfig("FillMode", "${cfg.workspace.wallpaperFillMode}");''}
}
'' else "");
wallpaperPlainColor = (if (cfg.workspace.wallpaperPlainColor != null) then ''
Expand Down
14 changes: 13 additions & 1 deletion modules/workspace.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

let
cfg = config.programs.plasma;
inherit (import ../lib/wallpapers.nix { inherit lib; }) wallpaperPictureOfTheDayType wallpaperSlideShowType;

inherit (import ../lib/wallpapers.nix { inherit lib; }) wallpaperPictureOfTheDayType wallpaperSlideShowType wallpaperFillModeTypes;

cursorType = with lib.types; submodule {
options = {
Expand Down Expand Up @@ -134,6 +135,17 @@ in
'';
};

wallpaperFillMode = lib.mkOption {
type = with lib.types; nullOr (enum (builtins.attrNames wallpaperFillModeTypes));
default = null;
example = "stretch";
description = ''
Defines how the wallpaper should be displayed on the screen.
Applies only to wallpaperPictureOfTheDay or wallpaperSlideShow.
'';
apply = value: if value == null then null else (builtins.toString wallpaperFillModeTypes.${value});
};

soundTheme = lib.mkOption {
type = with lib.types; nullOr str;
default = null;
Expand Down

0 comments on commit 88433d5

Please sign in to comment.