Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add wallpaperFillMode configuration option #338

Merged
merged 5 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
};
bemyak marked this conversation as resolved.
Show resolved Hide resolved
}
4 changes: 4 additions & 0 deletions modules/panels.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
} @ args:
let
cfg = config.programs.plasma;
inherit (import ../lib/wallpapers.nix { inherit lib; }) wallpaperFillModeTypes;

hasWidget = widgetName: builtins.any (panel: builtins.any (widget: widget.name == widgetName) panel.widgets) cfg.panels;

# An attrset keeping track of the packages which should be added when a
Expand Down Expand Up @@ -211,6 +213,7 @@ in
"\"" + (builtins.toString path) + "\"" else
"[" + (builtins.concatStringsSep "," (map (s: "\"" + s + "\"") path)) + "]"});
desktop.writeConfig("SlideInterval", "${builtins.toString cfg.workspace.wallpaperSlideShow.interval}");
desktop.writeConfig("FillMode", "${builtins.toString wallpaperFillModeTypes.${cfg.workspace.wallpaperFillMode}}");
bemyak marked this conversation as resolved.
Show resolved Hide resolved
}
'' else "");
wallpaperPOTD = (if (cfg.workspace.wallpaperPictureOfTheDay != null) then ''
Expand All @@ -221,6 +224,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"}");
desktop.writeConfig("FillMode", "${builtins.toString wallpaperFillModeTypes.${cfg.workspace.wallpaperFillMode}}");
bemyak marked this conversation as resolved.
Show resolved Hide resolved
}
'' else "");
wallpaperPlainColor = (if (cfg.workspace.wallpaperPlainColor != null) then ''
Expand Down
12 changes: 11 additions & 1 deletion modules/workspace.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

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

cursorType = with lib.types; submodule {
Expand Down Expand Up @@ -164,6 +164,16 @@ in
'';
};

wallpaperFillMode = with lib.types; lib.mkOption {
type = enum (lib.attrNames wallpaperFillModeTypes);
default = "Stretch";
example = "PreserveAspectFit";
description = ''
Defines how the wallpaper should be displayed on the screen.
Applies only to wallpaperPictureOfTheDay or wallpaperSlideShow.
'';
};
bemyak marked this conversation as resolved.
Show resolved Hide resolved

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