niri: make focus ring the inverse of the average of the background color

This commit is contained in:
2025-09-15 14:59:23 -04:00
parent 6d77b3a944
commit 6a5afb5e35
2 changed files with 32 additions and 1 deletions

View File

@@ -5,6 +5,9 @@
inputs, inputs,
... ...
}: }:
let
invert_image_avg = pkgs.callPackage ../util/inverse_color.nix;
in
{ {
imports = [ imports = [
inputs.niri.homeModules.config inputs.niri.homeModules.config
@@ -51,7 +54,9 @@
focus-ring = { focus-ring = {
enable = true; enable = true;
active = { active = {
color = "#bf7778"; color = builtins.readFile (invert_image_avg {
src = ../wallpaper.png;
});
}; };
}; };
}; };

View File

@@ -0,0 +1,26 @@
{
stdenv,
imagemagick,
gawk,
src,
}:
stdenv.mkDerivation {
pname = "invert-image-avg";
version = "1.0";
inherit src;
buildInputs = [
imagemagick
gawk
];
# input is a file, not a directory, skip unpackPhase
unpackPhase = "true";
# command taken from: https://old.reddit.com/r/swaywm/comments/oz3t7v/setting_a_blurred_background_with_swaylock_and/
buildPhase = ''
rm -fr $out
magick ${src} -channel RGB -negate -resize 1x1 txt: | awk 'FNR == 2 {print $3}' > $out
'';
}