Swappy: Patch the default color.

This commit is contained in:
Dmitry Voronin 2024-11-23 07:09:45 +03:00
parent 74609a80d8
commit 8bfcebcd27
Signed by: voronind
SSH key fingerprint: SHA256:3kBb4iV2ahufEBNq+vFbUe4QYfHt98DHQjN7QaptY9k
3 changed files with 51 additions and 0 deletions

View file

@ -42,6 +42,10 @@ in {
accent-g = mkStrOption stylix.colors.base0A-rgb-g; accent-g = mkStrOption stylix.colors.base0A-rgb-g;
accent-b = mkStrOption stylix.colors.base0A-rgb-b; 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-r = mkStrOption stylix.colors.base00-rgb-r;
bg-g = mkStrOption stylix.colors.base00-rgb-g; bg-g = mkStrOption stylix.colors.base00-rgb-g;
bg-b = mkStrOption stylix.colors.base00-rgb-b; bg-b = mkStrOption stylix.colors.base00-rgb-b;

16
overlay/Swappy.nix Normal file
View file

@ -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 <patch/swappy/DefaultColor.nix> args).file
];
});
})];
}

View file

@ -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;
'');
}