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

treewide: implement image editor #477

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion modules/feh/hm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
|| xmonad.enable
)
)
"${pkgs.feh}/bin/feh --no-fehbg --bg-scale ${config.stylix.image}";
"${pkgs.feh}/bin/feh --no-fehbg --bg-scale ${config.stylix.generated.image}";
}
2 changes: 1 addition & 1 deletion modules/feh/nixos.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
|| i3.enable
)
)
"${pkgs.feh}/bin/feh --no-fehbg --bg-scale ${config.stylix.image}";
"${pkgs.feh}/bin/feh --no-fehbg --bg-scale ${config.stylix.generated.image}";
}
4 changes: 2 additions & 2 deletions modules/gnome/hm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ in {
"org/gnome/desktop/background" = {
color-shading-type = "solid";
picture-options = "zoom";
picture-uri = "file://${config.stylix.image}";
picture-uri-dark = "file://${config.stylix.image}";
picture-uri = "file://${config.stylix.generated.image}";
picture-uri-dark = "file://${config.stylix.generated.image}";
};

"org/gnome/desktop/interface" = {
Expand Down
2 changes: 1 addition & 1 deletion modules/grub/nixos.nix
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ in {
${if config.stylix.targets.grub.useImage
# Make sure the background image is .png by asking to convert it
then
"${pkgs.imagemagick}/bin/convert ${config.stylix.image} png32:$out/background.png"
"${pkgs.imagemagick}/bin/convert ${config.stylix.generated.image} png32:$out/background.png"
else
"cp ${pixel "base00"} $out/background.png"}

Expand Down
4 changes: 2 additions & 2 deletions modules/hyprpaper/hm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
(config.stylix.enable && config.stylix.targets.hyprpaper.enable)
{
services.hyprpaper.settings = {
preload = [ "${config.stylix.image}" ];
wallpaper = [ ",${config.stylix.image}" ];
preload = [ "${config.stylix.generated.image}" ];
wallpaper = [ ",${config.stylix.generated.image}" ];
};
};
}
2 changes: 1 addition & 1 deletion modules/i3/hm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ in {
};
};

# output."*".bg = "${config.stylix.image} fill";
# output."*".bg = "${config.stylix.generated.image} fill";
};
})

Expand Down
2 changes: 1 addition & 1 deletion modules/kde/hm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ let
themePackage = pkgs.runCommandLocal "stylix-kde-theme" {
colorscheme = formatConfig colorscheme;
wallpaperMetadata = builtins.toJSON wallpaperMetadata;
wallpaperImage = config.stylix.image;
wallpaperImage = config.stylix.generated.image;
lookAndFeelMetadata = builtins.toJSON lookAndFeelMetadata;
lookAndFeelDefaults = formatConfig lookAndFeelDefaults;
} ''
Expand Down
2 changes: 1 addition & 1 deletion modules/lightdm/nixos.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
config.lib.stylix.mkEnableTarget "LightDM" true;

config.services.xserver.displayManager.lightdm.background =
lib.mkIf (config.stylix.enable && config.stylix.targets.lightdm.enable) config.stylix.image;
lib.mkIf (config.stylix.enable && config.stylix.targets.lightdm.enable) config.stylix.generated.image;
}
2 changes: 1 addition & 1 deletion modules/regreet/nixos.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
(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.generated.image;
font = {
inherit (config.stylix.fonts.sansSerif) name package;
};
Expand Down
2 changes: 1 addition & 1 deletion modules/sway/hm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ in {
};
};

output."*".bg = "${config.stylix.image} ${config.stylix.imageScalingMode}";
output."*".bg = "${config.stylix.generated.image} ${config.stylix.imageScalingMode}";

seat."*" = {
xcursor_theme = "${config.stylix.cursor.name} ${toString config.stylix.cursor.size}";
Expand Down
2 changes: 1 addition & 1 deletion modules/swaylock/hm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ in {
text-ver-color = text;
text-wrong-color = text;
} // lib.optionalAttrs config.stylix.targets.swaylock.useImage {
image = "${config.stylix.image}";
image = "${config.stylix.generated.image}";
};
};
}
2 changes: 1 addition & 1 deletion modules/wpaperd/hm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
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.generated.image}";
};
}
2 changes: 2 additions & 0 deletions stylix/home-manager-integration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ let
{ path = [ "stylix" "fonts" "sizes" "terminal" ]; }
{ path = [ "stylix" "fonts" "sizes" "popups" ]; }
{ path = [ "stylix" "image" ]; }
{ path = [ "stylix" "imageEditor" "enable"]; }
{ path = [ "stylix" "imageEditor" "method"]; }
{ path = [ "stylix" "imageScalingMode" ]; }
{ path = [ "stylix" "opacity" "desktop" ]; }
{ path = [ "stylix" "opacity" "applications" ]; }
Expand Down
11 changes: 11 additions & 0 deletions stylix/image-editors/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
config,
lib,
pkgs,
...
}:
{
config.lib.stylix.imageEditors = {
lutgen = import ./lutgen.nix { inherit lib config pkgs; };
};
}
14 changes: 14 additions & 0 deletions stylix/image-editors/lutgen.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
lib,
config,
pkgs,
...
}:
img:
let
colors = lib.strings.concatStringsSep " " config.lib.stylix.colors.toList;
baseName = builtins.baseNameOf img;
in
pkgs.runCommand baseName { } ''
${pkgs.lutgen}/bin/lutgen apply '${img}' --output "$out" -- ${colors}
''
69 changes: 69 additions & 0 deletions stylix/palette.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,56 @@ let
generatedScheme = lib.importJSON paletteJSON;

in {
imports = [
./image-editors
(lib.mkRemovedOptionModule [ "stylix" "palette" "base00" ] "Using stylix.palette to override scheme is not supported anymore")

# Added: 2023-02-02
(lib.mkRemovedOptionModule [ "stylix" "palette" "base01" ] "Using stylix.palette to override scheme is not supported anymore")

# Added: 2023-02-02
(lib.mkRemovedOptionModule [ "stylix" "palette" "base02" ] "Using stylix.palette to override scheme is not supported anymore")

# Added: 2023-02-02
(lib.mkRemovedOptionModule [ "stylix" "palette" "base03" ] "Using stylix.palette to override scheme is not supported anymore")

# Added: 2023-02-02
(lib.mkRemovedOptionModule [ "stylix" "palette" "base04" ] "Using stylix.palette to override scheme is not supported anymore")

# Added: 2023-02-02
(lib.mkRemovedOptionModule [ "stylix" "palette" "base05" ] "Using stylix.palette to override scheme is not supported anymore")

# Added: 2023-02-02
(lib.mkRemovedOptionModule [ "stylix" "palette" "base06" ] "Using stylix.palette to override scheme is not supported anymore")

# Added: 2023-02-02
(lib.mkRemovedOptionModule [ "stylix" "palette" "base07" ] "Using stylix.palette to override scheme is not supported anymore")

# Added: 2023-02-02
(lib.mkRemovedOptionModule [ "stylix" "palette" "base08" ] "Using stylix.palette to override scheme is not supported anymore")

# Added: 2023-02-02
(lib.mkRemovedOptionModule [ "stylix" "palette" "base09" ] "Using stylix.palette to override scheme is not supported anymore")

# Added: 2023-02-02
(lib.mkRemovedOptionModule [ "stylix" "palette" "base0A" ] "Using stylix.palette to override scheme is not supported anymore")

# Added: 2023-02-02
(lib.mkRemovedOptionModule [ "stylix" "palette" "base0B" ] "Using stylix.palette to override scheme is not supported anymore")

# Added: 2023-02-02
(lib.mkRemovedOptionModule [ "stylix" "palette" "base0C" ] "Using stylix.palette to override scheme is not supported anymore")

# Added: 2023-02-02
(lib.mkRemovedOptionModule [ "stylix" "palette" "base0D" ] "Using stylix.palette to override scheme is not supported anymore")

# Added: 2023-02-02
(lib.mkRemovedOptionModule [ "stylix" "palette" "base0E" ] "Using stylix.palette to override scheme is not supported anymore")

# Added: 2023-02-02
(lib.mkRemovedOptionModule [ "stylix" "palette" "base0F" ] "Using stylix.palette to override scheme is not supported anymore")
];

options.stylix = {
polarity = lib.mkOption {
type = lib.types.enum [ "either" "light" "dark" ];
Expand Down Expand Up @@ -55,6 +105,17 @@ in {
'';
};

imageEditor = {
enable = lib.mkEnableOption "Update `stylix.image` by applying `stylix.imageEditor.method` to the image";

method = lib.mkOption {
LovingMelody marked this conversation as resolved.
Show resolved Hide resolved
type = with lib.types; functionTo (coercedTo package toString path);
default = config.lib.stylix.imageEditors.lutgen;
description = "Edits the given `stylix.image` argument, outputs to `stylix.generated.image`";
example = "config.lib.stylix.imageEditors.lutgen;";
};
};

generated = {
json = lib.mkOption {
type = lib.types.path;
Expand All @@ -78,6 +139,14 @@ in {
readOnly = true;
internal = true;
};

image = lib.mkOption {
LovingMelody marked this conversation as resolved.
Show resolved Hide resolved
type = with lib.types; coercedTo package toString path;
default = cfg.image;
readOnly = true;
internal = true;
apply = img: if cfg.imageEditor.enable then cfg.imageEditor.method img else img;
};
};

base16Scheme = lib.mkOption {
Expand Down