11.stylix/modules/feh/nixos.nix
Flameopathic c8e4a0d218
treewide: optionalize stylix.image option (#717)
Optionalize the stylix.image option when stylix.base16Scheme is set,
making the following Stylix configurations valid:

    [
      // Now it possible to set 'stylix.image = null', if
      // stylix.base16Scheme is set.
      {
        base16Scheme = /* ... */;
      }

      // This configuration was already possible.
      {
        image = /* ... */;
      }

      // This configuration was already possible.
      {
        base16Scheme = /* ... */;
        image = /* ... */;
      }
    ]

Closes: https://github.com/danth/stylix/issues/200
Closes: https://github.com/danth/stylix/issues/442
Link: https://github.com/danth/stylix/pull/717

Co-authored-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
Reviewed-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
Tested-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
Reviewed-by: Daniel Thwaites <danth@danth.me>
2025-02-24 15:13:57 +01:00

42 lines
1 KiB
Nix

{
pkgs,
config,
lib,
...
}:
let
cfg = config.stylix.targets.feh;
in
{
options.stylix.targets.feh = {
enable = config.lib.stylix.mkEnableTarget "the desktop background using Feh" (
config.stylix.image != null
);
};
config.services.xserver.displayManager.sessionCommands =
lib.mkIf
(
config.stylix.enable
&& cfg.enable
&& (with config.services.xserver.windowManager; xmonad.enable || i3.enable)
)
(
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}"
);
}