From 8bfcebcd2721ac65e708ecc9a4c1bc6deb2e3153 Mon Sep 17 00:00:00 2001 From: Dmitry Voronin Date: Sat, 23 Nov 2024 07:09:45 +0300 Subject: [PATCH] Swappy: Patch the default color. --- option/Style.nix | 4 ++++ overlay/Swappy.nix | 16 ++++++++++++++++ patch/swappy/DefaultColor.nix | 31 +++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 overlay/Swappy.nix create mode 100644 patch/swappy/DefaultColor.nix diff --git a/option/Style.nix b/option/Style.nix index d1edaf01..875a5d5c 100644 --- a/option/Style.nix +++ b/option/Style.nix @@ -42,6 +42,10 @@ in { accent-g = mkStrOption stylix.colors.base0A-rgb-g; accent-b = mkStrOption stylix.colors.base0A-rgb-b; + accent-dec-r = mkStrOption stylix.colors.base0A-dec-r; + accent-dec-g = mkStrOption stylix.colors.base0A-dec-g; + accent-dec-b = mkStrOption stylix.colors.base0A-dec-b; + bg-r = mkStrOption stylix.colors.base00-rgb-r; bg-g = mkStrOption stylix.colors.base00-rgb-g; bg-b = mkStrOption stylix.colors.base00-rgb-b; diff --git a/overlay/Swappy.nix b/overlay/Swappy.nix new file mode 100644 index 00000000..8137a413 --- /dev/null +++ b/overlay/Swappy.nix @@ -0,0 +1,16 @@ +{ + __findFile, + config, + pkgs, + util, + ... +} @args: { + # SEE: https://github.com/jtheoof/swappy/issues/131 + nixpkgs.overlays = [(final: prev: { + swappy = prev.swappy.overrideAttrs (old: { + patches = (old.patches or [ ]) ++ [ + (import args).file + ]; + }); + })]; +} diff --git a/patch/swappy/DefaultColor.nix b/patch/swappy/DefaultColor.nix new file mode 100644 index 00000000..fa50f975 --- /dev/null +++ b/patch/swappy/DefaultColor.nix @@ -0,0 +1,31 @@ +{ + config, + pkgs, + util, + ... +}: let + color = config.module.style.color; + accentR = color.accent-dec-r; + accentG = color.accent-dec-g; + accentB = color.accent-dec-b; +in { + file = pkgs.writeText "SwappyDefaultColorPatch" (util.trimTabs '' +diff --git a/src/application.c b/src/application.c +index 5b98590..86788b6 100644 +--- a/src/application.c ++++ b/src/application.c +@@ -875,9 +875,9 @@ static gboolean is_file_from_stdin(const char *file) { + } + + static void init_settings(struct swappy_state *state) { +- state->settings.r = 1; +- state->settings.g = 0; +- state->settings.b = 0; ++ state->settings.r = ${accentR}; ++ state->settings.g = ${accentG}; ++ state->settings.b = ${accentB}; + state->settings.a = 1; + state->settings.w = state->config->line_size; + state->settings.t = state->config->text_size; + ''); +}