aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatasha Moongrave <natasha@256phi.eu>2026-04-20 12:02:54 +0200
committerNatasha Moongrave <natasha@256phi.eu>2026-04-20 12:02:54 +0200
commite2abac4c7241b783150301b62617c91624195cc8 (patch)
tree848c027a0660397dd78488443fa5001a209661ca
parentbe42662aae4364adf803b3b860dbb04319ee9f65 (diff)
Add open animations to niri
-rw-r--r--home/rices/finals/niri.nix2
-rw-r--r--home/rices/finals/niri/shaders/arc.frag131
2 files changed, 133 insertions, 0 deletions
diff --git a/home/rices/finals/niri.nix b/home/rices/finals/niri.nix
index b4e012b..190eb30 100644
--- a/home/rices/finals/niri.nix
+++ b/home/rices/finals/niri.nix
@@ -19,10 +19,12 @@
(map (lib.concatStringsSep " ")
(map (map (word: "\"${word}\""))
[
+ ["eww" "open" "clock"]
["touch" ".config/niri/live.kdl"]
]));
other = [
"include \"live.kdl\""
+ "animations { window-open { duration-ms 3000; curve \"linear\"; custom-shader r\"\n${builtins.readFile ./niri/shaders/arc.frag}\";};}"
];
in {
target = ".config/niri/config.kdl";
diff --git a/home/rices/finals/niri/shaders/arc.frag b/home/rices/finals/niri/shaders/arc.frag
new file mode 100644
index 0000000..301357c
--- /dev/null
+++ b/home/rices/finals/niri/shaders/arc.frag
@@ -0,0 +1,131 @@
+
+#define PI 3.14159
+
+#define TAU 6.28319
+
+#define WIDTH 3.
+#define RADIUS 1.
+
+#define WIPE_DURATION .2
+#define BORDER_LOOPS 3.
+#define FADE_ITS 2.
+
+vec4 gradi(float pos, vec4 bg, vec4 fg, float fac, float mask) {
+ if (mask < 0.2) {
+ return bg;
+ }
+
+ vec4 trans = vec4(0.);
+ vec4 purple = vec4(0.45, 0.13, 0.49, 1.0) * vec4(mask);
+ vec4 blue = vec4(0.25, 0.74, 0.81, 1.0) * vec4(mask);
+ vec4 white = vec4(mask);
+ float mult = 4. * fac;
+
+ if (pos <= 0.125) {
+ return mix(bg, purple, max(0., pos * mult));
+ } else if (pos <= 0.25) {
+ return mix(purple, blue, (pos * mult) - 1.);
+ } else if (pos <= 0.5) {
+ return mix(blue, white, (pos * mult) - 2.);
+ } else {
+ return fg;
+ }
+
+}
+
+// from niri source code: https://github.com/YaLTeR/niri/blob/f30db163b5748e8cf95c05aba77d0d3736f40543/src/render_helpers/shaders/border.frag#L211-L234
+float rounding_alpha(vec2 coords, vec2 size, vec4 corner_radius) {
+ vec2 center;
+ float radius;
+
+ if (coords.x < corner_radius.x && coords.y < corner_radius.x) {
+ radius = corner_radius.x;
+ center = vec2(radius, radius);
+ } else if (size.x - corner_radius.y < coords.x && coords.y < corner_radius.y) {
+ radius = corner_radius.y;
+ center = vec2(size.x - radius, radius);
+ } else if (size.x - corner_radius.z < coords.x && size.y - corner_radius.z < coords.y) {
+ radius = corner_radius.z;
+ center = vec2(size.x - radius, size.y - radius);
+ } else if (coords.x < corner_radius.w && size.y - corner_radius.w < coords.y) {
+ radius = corner_radius.w;
+ center = vec2(radius, size.y - radius);
+ } else {
+ return 1.0;//
+ }
+
+ float dist = distance(coords, center);
+ float half_px = 0.5;
+ return 1.0 - smoothstep(radius - half_px, radius + half_px, dist);
+}
+
+vec4 open_color(vec3 coords_geo, vec3 size_geo) {
+ vec4 bg1 = vec4(.1, .1, .18, 1.0);
+ vec4 bg2 = vec4(.09, .05, .11, 1.0);
+
+ vec3 coords_tex = niri_geo_to_tex * coords_geo;
+ vec4 color = texture2D(niri_tex, coords_tex.st);
+
+ float pi = radians(180.);
+
+ if (0.0 <= coords_geo.x && coords_geo.x <= 1.0
+ && 0.0 <= coords_geo.y && coords_geo.y <= 1.0)
+ {
+ float pos = (coords_tex.x - ((1. / WIPE_DURATION) * niri_clamped_progress) * 2.) + 1.;
+ vec2 coords = (coords_geo.xy - vec2(0.5, 0.5)) * size_geo.xy * 2.0;
+ vec2 coords_abs = coords_geo.xy * size_geo.xy;
+
+ float border_a = 1.;
+
+ border_a *= rounding_alpha(
+ coords_abs.xy,
+ size_geo.xy,
+ vec4(RADIUS + WIDTH)
+ );
+
+ vec4 bg = mix(bg1, bg2, length(coords_tex.xy - vec2(1., 0.))) * border_a;
+
+ color = gradi(pos, color, bg, 2.0, border_a);
+
+ float angle = (atan(coords.y, coords.x) + PI) / TAU;
+ float spinny_angle = mod((angle + niri_clamped_progress * BORDER_LOOPS), 1.0) / 2.;
+
+ vec2 border = WIDTH / size_geo.xy;
+
+ float temp = border_a;
+ float round_a = 1. - rounding_alpha(
+ coords_abs.xy - WIDTH,
+ size_geo.xy - WIDTH * 2.,
+ vec4(RADIUS)
+ );
+
+ if (coords_geo.x <= border.x || coords_geo.x >= (1. - border.x) ||
+ coords_geo.y <= border.y || coords_geo.y >= (1. - border.y)) {
+ border_a *= round_a;
+ }
+
+ float rest = 0.;
+ if (border_a + temp == 1.) {
+ rest = 1.;
+ }
+
+ border_a *= round_a;
+ border_a += rest;
+
+ vec4 grad = gradi(
+ spinny_angle,
+ vec4(.48, .37, .5, 1.),
+ vec4(1., 0., 0., 1.),
+ 2.0, // DO NOT TOUCH
+ border_a
+ );
+
+ if ((1. - niri_clamped_progress) < FADE_ITS / BORDER_LOOPS) {
+ border_a *= (1. - niri_clamped_progress) / (FADE_ITS / BORDER_LOOPS);
+ }
+ color = mix(color, grad, border_a);
+
+ }
+
+ return color;
+}