Skip to content

Commit

Permalink
treewide: extend stylix.imageScalingMode support
Browse files Browse the repository at this point in the history
Add stylix.imageScalingMode support to all modules except:

- hyprlock
- hyprpaper
- kde
- lightdm
- sway

Closes: #677
Link: #678

Reviewed-by: NAHO <[email protected]>
Reviewed-by: Daniel Thwaites <[email protected]>
(cherry picked from commit a2d66f2)
  • Loading branch information
justDeeevin authored and trueNAHO committed Jan 4, 2025
1 parent 9015d5d commit 8cdd9f0
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 8 deletions.
16 changes: 14 additions & 2 deletions modules/feh/hm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@
|| spectrwm.enable
|| xmonad.enable
)
)
"${pkgs.feh}/bin/feh --no-fehbg --bg-scale ${config.stylix.image}";
) (let
inherit (config.stylix) imageScalingMode;
bg-arg =
if imageScalingMode == "fill"
then "--bg-fill"
else if imageScalingMode == "center"
then "--bg-center"
else if imageScalingMode == "tile"
then "--bg-tile"
else if imageScalingMode == "stretch"
then "--bg-scale"
# Fit
else "--bg-max";
in "${pkgs.feh}/bin/feh --no-fehbg ${bg-arg} ${config.stylix.image}");
}
15 changes: 14 additions & 1 deletion modules/feh/nixos.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,18 @@
|| i3.enable
)
)
"${pkgs.feh}/bin/feh --no-fehbg --bg-scale ${config.stylix.image}";
(let
inherit (config.stylix) imageScalingMode;
bg-arg =
if imageScalingMode == "fill"
then "--bg-fill"
else if imageScalingMode == "center"
then "--bg-center"
else if imageScalingMode == "tile"
then "--bg-tile"
else if imageScalingMode == "stretch"
then "--bg-scale"
# Fit
else "--bg-max";
in "${pkgs.feh}/bin/feh --no-fehbg ${bg-arg} ${config.stylix.image}");
}
14 changes: 13 additions & 1 deletion modules/gnome/hm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,19 @@ in {
dconf.settings = {
"org/gnome/desktop/background" = {
color-shading-type = "solid";
picture-options = "zoom";
picture-options = let
inherit (config.stylix) imageScalingMode;
in
if imageScalingMode == "fit"
then "scaled"
else if imageScalingMode == "fill"
then "zoom"
else if imageScalingMode == "stretch"
then "stretched"
else if imageScalingMode == "center"
then "centered"
# Seemingly no tile support... :(
else "zoom";
picture-uri = "file://${config.stylix.image}";
picture-uri-dark = "file://${config.stylix.image}";
};
Expand Down
13 changes: 12 additions & 1 deletion modules/grub/nixos.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ let
${pkgs.grub2}/bin/grub-mkfont $font --output $out --size ${toString sizes.applications}
'';

inherit (config.stylix) imageScalingMode;

image-scale =
if imageScalingMode == "fill"
then "crop"
else if imageScalingMode == "fit"
then "fitheight"
else if imageScalingMode == "center"
then "padding"
# Grub doesn't seem to support tile
else "crop";
in {
options.stylix.targets.grub = {
enable = config.lib.stylix.mkEnableTarget "GRUB" true;
Expand All @@ -46,7 +57,7 @@ in {
theme = pkgs.runCommand "stylix-grub" {
themeTxt = ''
desktop-image: "background.png"
desktop-image-scale-method: "crop"
desktop-image-scale-method: "${image-scale}"
desktop-color: "${base00}"
title-text: ""
Expand Down
15 changes: 14 additions & 1 deletion modules/regreet/nixos.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,20 @@
(config.stylix.enable && config.stylix.targets.regreet.enable && pkgs.stdenv.hostPlatform.isLinux)
{
programs.regreet = {
settings.background.path = config.stylix.image;
settings.background = {
path = config.stylix.image;
fit = let
inherit (config.stylix) imageScalingMode;
in
if imageScalingMode == "fill"
then "Cover"
else if imageScalingMode == "fit"
then "Contain"
else if imageScalingMode == "stretch"
then "Fill"
# No other available options
else null;
};
font = {
inherit (config.stylix.fonts.sansSerif) name package;
};
Expand Down
2 changes: 1 addition & 1 deletion modules/swaylock/hm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ in {
config = lib.mkIf (config.stylix.enable && config.stylix.targets.swaylock.enable && pkgs.stdenv.hostPlatform.isLinux) {
programs.swaylock.settings = {
color = outside;
scaling = "fill";
scaling = config.stylix.imageScalingMode;
inside-color = inside;
inside-clear-color = inside;
inside-caps-lock-color = inside;
Expand Down
10 changes: 9 additions & 1 deletion modules/wpaperd/hm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
options.stylix.targets.wpaperd.enable = config.lib.stylix.mkEnableTarget "wpaperd" true;

config = lib.mkIf (config.stylix.enable && config.stylix.targets.wpaperd.enable) {
programs.wpaperd.settings.any.path = "${config.stylix.image}";
programs.wpaperd.settings.any = {
path = "${config.stylix.image}";
mode = let
inherit (config.stylix) imageScalingMode;
in
if imageScalingMode == "fill"
then "fit"
else imageScalingMode;
};
};
}

0 comments on commit 8cdd9f0

Please sign in to comment.