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

Further implementation of stylix.imageScalingMode #678

Merged
merged 8 commits into from
Dec 18, 2024
Merged
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;
};
};
}
Loading