niri flame close effect; add zen

This commit is contained in:
EdenQwQ 2025-05-31 10:53:23 +08:00
parent b0dd564d30
commit c3172230d0
13 changed files with 603 additions and 10 deletions

142
flake.lock generated
View file

@ -306,6 +306,24 @@
"type": "github"
}
},
"flake-parts_8": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib_7"
},
"locked": {
"lastModified": 1743550720,
"narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "c621e8422220273271f52058f618c94e405bb0f5",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"flake-root": {
"locked": {
"lastModified": 1723604017,
@ -537,6 +555,27 @@
"type": "github"
}
},
"home-manager_4": {
"inputs": {
"nixpkgs": [
"zen-browser",
"nixpkgs"
]
},
"locked": {
"lastModified": 1743604125,
"narHash": "sha256-ZD61DNbsBt1mQbinAaaEqKaJk2RFo9R/j+eYWeGMx7A=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "180fd43eea296e62ae68e079fcf56aba268b9a1a",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"ixx": {
"inputs": {
"flake-utils": [
@ -652,11 +691,11 @@
"nixpkgs": "nixpkgs_4"
},
"locked": {
"lastModified": 1746889600,
"narHash": "sha256-I82pvD0mdInsQTFA7SisvmJAusgdp8hJXLFBVd73URw=",
"lastModified": 1748096601,
"narHash": "sha256-ji/9z1pRbosyKVVAIGBazyz6PjWV8bc2Ux2RdQrVDWY=",
"owner": "viperML",
"repo": "nh",
"rev": "9bbd96385f5534ccc2ba7f0b3c29192d7f0eb68c",
"rev": "1ea27e73a3dcbc9950258e9054377ee677d12b9e",
"type": "github"
},
"original": {
@ -732,11 +771,11 @@
"niri-unstable": {
"flake": false,
"locked": {
"lastModified": 1747486745,
"narHash": "sha256-ngQ+iTHmBJkEbsjYfCWTJdV8gHhOCTkV8K0at6Y+YHI=",
"lastModified": 1748151941,
"narHash": "sha256-z4viQZLgC2bIJ3VrzQnR+q2F3gAOEQpU1H5xHtX/2fs=",
"owner": "YalTeR",
"repo": "niri",
"rev": "ae89cb6017668f3a81ccd92461cbbc70ab8377d0",
"rev": "8ba57fcf25d2fc9565131684a839d58703f1dae7",
"type": "github"
},
"original": {
@ -868,6 +907,21 @@
"type": "github"
}
},
"nixpkgs-lib_7": {
"locked": {
"lastModified": 1743296961,
"narHash": "sha256-b1EdN3cULCqtorQ4QeWgLMrd5ZGOjLSLemfa00heasc=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "e4822aea2a6d1cdd36653c134cacfd64c97ff4fa",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1747335874,
@ -940,6 +994,22 @@
"type": "github"
}
},
"nixpkgs_10": {
"locked": {
"lastModified": 1745794561,
"narHash": "sha256-T36rUZHUART00h3dW4sV5tv4MrXKT7aWjNfHiZz7OHg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5461b7fa65f3ca74cef60be837fd559a8918eaa0",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1742800061,
@ -1178,7 +1248,9 @@
"nur": "nur",
"scroll": "scroll",
"stylix": "stylix",
"treefmt-nix": "treefmt-nix_5"
"treefmt-nix": "treefmt-nix_5",
"zen-browser": "zen-browser",
"zen-nebula": "zen-nebula"
}
},
"rust-overlay": {
@ -1360,6 +1432,21 @@
"type": "github"
}
},
"systems_8": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"tinted-foot": {
"flake": false,
"locked": {
@ -1576,6 +1663,47 @@
"repo": "xwayland-satellite",
"type": "github"
}
},
"zen-browser": {
"inputs": {
"home-manager": "home-manager_4",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1748143192,
"narHash": "sha256-KvP468pbSw0c6fXQmd4Q2tp/ywxvxrz5ijRT3odniaw=",
"owner": "0xc000022070",
"repo": "zen-browser-flake",
"rev": "04d982716fb6c1fc64e0de6e55103b15c892ceda",
"type": "github"
},
"original": {
"owner": "0xc000022070",
"repo": "zen-browser-flake",
"type": "github"
}
},
"zen-nebula": {
"inputs": {
"flake-parts": "flake-parts_8",
"nixpkgs": "nixpkgs_10",
"systems": "systems_8"
},
"locked": {
"lastModified": 1748029858,
"narHash": "sha256-ICMQ+OxPk8q75LxfPJbUv6fUwzd9L19u1RzCRcuUjic=",
"owner": "JustAdumbPrsn",
"repo": "Zen-Nebula",
"rev": "5df76a2776a9aec0e280a1ff8dbee397221b94a8",
"type": "github"
},
"original": {
"owner": "JustAdumbPrsn",
"repo": "Zen-Nebula",
"type": "github"
}
}
},
"root": "root",

View file

@ -55,6 +55,7 @@
flake-parts.url = "github:hercules-ci/flake-parts";
niri-unstable = {
url = "github:YalTeR/niri";
# url = "github:visualglitch91/niri/feat/blur-lite";
flake = false;
};
niri = {
@ -87,5 +88,10 @@
url = "github:dawsers/scroll";
flake = false;
};
zen-nebula.url = "github:JustAdumbPrsn/Zen-Nebula";
zen-browser = {
url = "github:0xc000022070/zen-browser-flake";
inputs.nixpkgs.follows = "nixpkgs";
};
};
}

View file

@ -3,5 +3,6 @@
./firefox.nix
./chromium.nix
./qutebrowser.nix
./zen.nix
];
}

View file

@ -0,0 +1,10 @@
{
zen-nebula = {
enable = true;
profile = "default";
};
programs.zen-browser = {
enable = true;
profiles.default.isDefault = true;
};
}

View file

@ -5,7 +5,7 @@ in
{
home.packages = with pkgs; [
(config.lib.misc.addFlags
"--enable-features=UseOzonePlatform --ozone-platform=wayland --use-gl=angle --wayland-text-input-version=3"
"--enable-features=UseOzonePlatform --ozone-platform=wayland --use-gl=angle --enable-wayland-ime --wayland-text-input-version=3"
"rstudio"
myRstudio
)

View file

@ -1,3 +1,4 @@
{ config, ... }:
{
programs.niri.settings.animations = {
window-open = {
@ -10,7 +11,7 @@
window-close = {
easing = {
curve = "ease-out-quad";
duration-ms = 500;
duration-ms = 1000;
};
};
workspace-switch = {
@ -96,6 +97,234 @@
return default_open(coords_geo, size_geo);
}
'';
window-close =
let
inherit (config.lib.stylix) colors;
mkColor =
color:
let
r = colors."${color}-rgb-r";
g = colors."${color}-rgb-g";
b = colors."${color}-rgb-b";
rf = "${r}.0 / 255.0";
gf = "${g}.0 / 255.0";
bf = "${b}.0 / 255.0";
in
"vec4(${rf}, ${gf}, ${bf}, 1.0)";
in
# glsl
''
// copied from https://github.com/ogios/dots/blob/master/niri/fire-close.frag
// easeOutQuad 线使
float easeOutQuad(float x) {
return 1.0 - (1.0 - x) * (1.0 - x);
}
float getEdgeMask(vec2 uv, float fadeWidth) {
float mask = 1.0;
mask *= smoothstep(0.0, 1.0, clamp(uv.x / fadeWidth, 0.0, 1.0));
mask *= smoothstep(0.0, 1.0, clamp(uv.y / fadeWidth, 0.0, 1.0));
mask *= smoothstep(0.0, 1.0, clamp((1.0 - uv.x) / fadeWidth, 0.0, 1.0));
mask *= smoothstep(0.0, 1.0, clamp((1.0 - uv.y) / fadeWidth, 0.0, 1.0));
return mask;
}
//
// x
// y
vec2 fireEffectMask(vec2 uv, float progress) {
const float HIDE_TIME = 0.4;
const float FADE_WIDTH = 0.1;
float p = easeOutQuad(progress);
float burnProgress = clamp(p / HIDE_TIME, 0.0, 1.0);
float afterBurnProgress = clamp((p - HIDE_TIME) / (1.0 - HIDE_TIME), 0.0, 1.0);
float t = uv.y * (1.0 - FADE_WIDTH);
float windowMask = 1.0 - clamp((burnProgress - t) / FADE_WIDTH, 0.0, 1.0);
float effectMask = clamp(t * (1.0 - windowMask) / burnProgress, 0.0, 1.0);
if (p > HIDE_TIME) {
float fade = sqrt(1.0 - afterBurnProgress * afterBurnProgress);
effectMask *= mix(1.0, 1.0 - t, afterBurnProgress) * fade;
}
effectMask *= getEdgeMask(uv, FADE_WIDTH);
return vec2(windowMask, effectMask);
}
// 0..1 5
vec4 getFireColor(float v) {
float steps[5];
steps[0] = 0.0;
steps[1] = 0.2;
steps[2] = 0.35;
steps[3] = 0.5;
steps[4] = 0.8;
vec4 colors[5];
colors[0] = ${mkColor "base00"} * 1.0;
colors[1] = ${mkColor "base08"} * 1.0;
colors[2] = ${mkColor "base09"} * 1.0;
colors[3] = ${mkColor "base0A"} * 1.0;
colors[4] = ${mkColor "base05"} * 1.0;
if (v < steps[0]) {
return colors[0];
}
for (int i = 0; i < 4; ++i) {
if (v <= steps[i + 1]) {
float t = (v - steps[i]) / (steps[i + 1] - steps[i]);
return mix(colors[i], colors[i + 1], t);
}
}
return colors[4];
}
// alphaOver alpha fg bg
vec4 alphaOver(vec4 bg, vec4 fg) {
return fg + (1.0 - fg.a) * bg;
}
// 3 out, 3 in...
vec3 hash33(vec3 p3) {
p3 = fract(p3 * vec3(.1031, .1030, .0973));
p3 += dot(p3, p3.yxz + 33.33);
return fract((p3.xxy + p3.yxx) * p3.zyx);
}
// 3D Simplex Noise
// MIT License, https://www.shadertoy.com/view/XsX3zB
// Copyright © 2013 Nikita Miropolskiy
float simplex3D(vec3 p) {
// skew constants for 3D simplex functions
const float F3 = 0.3333333;
const float G3 = 0.1666667;
// 1. find current tetrahedron T and it's four vertices
// s, s+i1, s+i2, s+1.0 - absolute skewed (integer) coordinates of T vertices
// x, x1, x2, x3 - unskewed coordinates of p relative to each of T vertice
// calculate s and x
vec3 s = floor(p + dot(p, vec3(F3)));
vec3 x = p - s + dot(s, vec3(G3));
// calculate i1 and i2
vec3 e = step(vec3(0.0), x - x.yzx);
vec3 i1 = e * (1.0 - e.zxy);
vec3 i2 = 1.0 - e.zxy * (1.0 - e);
// x1, x2, x3
vec3 x1 = x - i1 + G3;
vec3 x2 = x - i2 + 2.0 * G3;
vec3 x3 = x - 1.0 + 3.0 * G3;
// 2. find four surflets and store them in d
vec4 w, d;
// calculate surflet weights
w.x = dot(x, x);
w.y = dot(x1, x1);
w.z = dot(x2, x2);
w.w = dot(x3, x3);
// w fades from 0.6 at the center of the surflet to 0.0 at the margin
w = max(0.6 - w, 0.0);
// calculate surflet components
d.x = dot(-0.5 + hash33(s), x);
d.y = dot(-0.5 + hash33(s + i1), x1);
d.z = dot(-0.5 + hash33(s + i2), x2);
d.w = dot(-0.5 + hash33(s + 1.0), x3);
// multiply d by w^4
w *= w;
w *= w;
d *= w;
// 3. return the sum of the four surflets
return dot(d, vec4(52.0)) * 0.5 + 0.5;
}
// Directional artifacts can be reduced by rotating each octave
float simplex3DFractal(vec3 m) {
// const matrices for 3D rotation
const mat3 rot1 = mat3(-0.37, 0.36, 0.85, -0.14, -0.93, 0.34, 0.92, 0.01, 0.4);
const mat3 rot2 = mat3(-0.55, -0.39, 0.74, 0.33, -0.91, -0.24, 0.77, 0.12, 0.63);
const mat3 rot3 = mat3(-0.71, 0.52, -0.47, -0.08, -0.72, -0.68, -0.7, -0.45, 0.56);
return 0.5333333 * simplex3D(m * rot1) + 0.2666667 * simplex3D(2.0 * m * rot2) +
0.1333333 * simplex3D(4.0 * m * rot3) + 0.0666667 * simplex3D(8.0 * m);
}
// fire
vec4 close_color(vec3 coords_geo, vec3 size_geo) {
// bool inside = 0.0 <= coords_geo.x && coords_geo.x <= 1.0
// && 0.0 <= coords_geo.y && coords_geo.y <= 1.0;
// // Paint only the area inside the current geometry.
// if (!inside)
// {
// return vec4(0.0, 0.0, 0.0, 0.0);
// }
// [0,1]
vec2 uv = coords_geo.st;
//
float movementSpeed = 0.7;
uv.y += niri_progress * movementSpeed;
//
float noiseScale = 4.0;
vec2 noiseUV = uv * noiseScale;
float noiseVal = simplex3DFractal(vec3(uv * 4.0, niri_progress * movementSpeed * 1.5));
//
vec4 fireColor = getFireColor(noiseVal);
//
vec2 masks = fireEffectMask(coords_geo.xy, niri_progress);
float windowMask = masks.x;
float effectMask = masks.y;
// 使 vec2 vec3
vec2 texCoords = (niri_geo_to_tex * coords_geo).xy;
vec4 windowColor = texture2D(niri_tex, texCoords);
// alpha使
windowColor.a *= windowMask;
windowColor.r *= windowMask;
windowColor.g *= windowMask;
windowColor.b *= windowMask;
//
fireColor *= effectMask;
// // fade edge horizontal
// float threshold = 0.03;
// if (coords_geo.x < threshold) {
// fireColor *= coords_geo.x / threshold;
// } else if (coords_geo.x > 1.0 - threshold) {
// fireColor *= (1.0 - coords_geo.x) / threshold;
// }
//
// // fade edge bottom
// if (coords_geo.y > 1.0 - threshold) {
// fireColor *= (1.0 - coords_geo.y) / threshold;
// }
vec4 finalColor = alphaOver(windowColor, fireColor);
return finalColor;
}
'';
window-resize =
# glsl
''

View file

@ -8,7 +8,6 @@ let
niri-autostart = pkgs.writeShellApplication {
name = "niri-autostart";
runtimeInputs = with pkgs; [
niri-blur-wallpaper
swww
clash-meta
wlsunset

View file

@ -17,9 +17,19 @@ let
builtins.replaceStrings
[
"output \"${config.lib.monitors.mainMonitorName}\" {"
# "layout {"
]
[
"output \"${config.lib.monitors.mainMonitorName}\" {\nfocus-at-startup"
# ''
# layout {
# blur {
# on
# passes 2
# radius 5
# noise 0.1
# }
# ''
]
config.programs.niri.finalConfig
+ "\n"

View file

@ -7,3 +7,5 @@ if [ -z $wall ]; then
fi
output=$(niri msg -j focused-output | jq -r .name)
swww img -o $output $wallpapers_dir/$wall --transition-type random --transition-duration 1
blurwall=$(echo $wall | sed 's/\.jpg$/-blurred.jpg/')
swaybg -o $output -i $wallpapers_dir/$blurwall -m fill

View file

@ -23,6 +23,8 @@ let
inputs.agenix.homeManagerModules.default
../secrets/age.nix
inputs.maomaowm.hmModules.maomaowm
inputs.zen-nebula.homeModules.default
inputs.zen-browser.homeModules.twilight
] ++ (builtins.attrValues self.homeManagerModules);
mkHost =

View file

@ -20,6 +20,7 @@ let
ez
multcomp
rsdmx
MuMIn
];
in
{

View file

@ -9,4 +9,5 @@
fiz = pkgs.callPackage ./fiz.nix { };
hellwm = pkgs.callPackage ./hellwm.nix { };
wallpapers = pkgs.callPackage ./wallpapers.nix { };
wechat = pkgs.callPackage ./wechat.nix { };
}

204
pkgs/wechat.nix Normal file
View file

@ -0,0 +1,204 @@
{
lib,
stdenv,
appimageTools,
fetchurl,
undmg,
makeWrapper,
nss,
nspr,
xorg,
pango,
zlib,
atkmm,
libdrm,
libxkbcommon,
xcbutilwm,
xcbutilimage,
xcbutilkeysyms,
xcbutilrenderutil,
mesa,
alsa-lib,
wayland,
atk,
qt6,
at-spi2-atk,
at-spi2-core,
dbus,
cups,
gtk3,
libxml2,
cairo,
freetype,
fontconfig,
vulkan-loader,
gdk-pixbuf,
libexif,
ffmpeg,
pulseaudio,
systemd,
libuuid,
expat,
bzip2,
glib,
libva,
libGL,
libnotify,
}:
let
pname = "wechat";
inherit (stdenv.hostPlatform) system;
src = fetchurl {
url =
{
x86_64-linux = "https://web.archive.org/web/20241107191621/https://dldir1v6.qq.com/weixin/Universal/Linux/WeChatLinux_x86_64.AppImage";
aarch64-linux = "https://web.archive.org/web/20241107192345/https://dldir1v6.qq.com/weixin/Universal/Linux/WeChatLinux_arm64.AppImage";
x86_64-darwin = "https://web.archive.org/web/20241107193311/https://dldir1v6.qq.com/weixin/Universal/Mac/WeChatMac_x86_64.dmg";
aarch64-darwin = "http://web.archive.org/web/20241107194014/https://dldir1v6.qq.com/weixin/Universal/Mac/WeChatMac_arm64.dmg";
}
.${system};
hash =
{
x86_64-linux = "sha256-aleVKrsZsM6k4vbIc79pJ2DmV+hGvUPkOTmiDqCquUE=";
aarch64-linux = "sha256-7xLL7r/xFK2qr7oyTnG5+nioZCKRZVgNMhU44RD2Zu4=";
x86_64-darwin = "sha256-IMG3By5CnZOwxjOyIUG79XZ8g1HrYY2GkuvUd4Ekpqs=";
aarch64-darwin = "sha256-1ocgPaOOn+FntBCuVcKsFJanhCKgQH3lqRuGsfOvp2c=";
}
.${system};
};
meta = {
description = "Connecting a billion people with calls, chats, and more";
mainProgram = "wechat";
homepage = "https://weixin.qq.com";
license = lib.licenses.unfree;
maintainers = with lib.maintainers; [ ulysseszhan ];
platforms = [
"x86_64-linux"
"x86_64-darwin"
"aarch64-darwin"
"aarch64-linux"
];
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
};
# See #335658
glibcWithoutHardening = stdenv.cc.libc.overrideAttrs (old: {
hardeningDisable = (old.hardeningDisable or [ ]) ++ [ "zerocallusedregs" ];
});
# Copied from wechat-uos package
wechat-runtime = with xorg; [
# Make sure our glibc without hardening gets picked up first
(lib.hiPrio glibcWithoutHardening)
stdenv.cc.cc
stdenv.cc.libc
pango
zlib
xcbutilwm
xcbutilimage
xcbutilkeysyms
xcbutilrenderutil
libX11
libXt
libXext
libSM
libICE
libxcb
libxkbcommon
libxshmfence
libXi
libXft
libXcursor
libXfixes
libXScrnSaver
libXcomposite
libXdamage
libXtst
libXrandr
libnotify
atk
atkmm
cairo
at-spi2-atk
at-spi2-core
alsa-lib
dbus
cups
gtk3
gdk-pixbuf
libexif
ffmpeg
libva
freetype
fontconfig
libXrender
libuuid
expat
glib
nss
nspr
libGL
libxml2
pango
libdrm
mesa
vulkan-loader
systemd
wayland
pulseaudio
qt6.qt5compat
bzip2
];
linux = appimageTools.wrapType2 rec {
inherit pname src meta;
version = "4.0.0.30";
nativeBuildInputs = [ makeWrapper ];
profile = ''
export LC_ALL=C.UTF-8
'';
extraInstallCommands =
let
appimageContents = appimageTools.extractType2 {
inherit (linux) pname version src;
};
in
''
wrapProgram $out/bin/${pname} \
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \
--set LD_LIBRARY_PATH "${lib.makeLibraryPath wechat-runtime}"
install -Dm444 ${appimageContents}/wechat.desktop -t $out/share/applications
install -Dm444 ${appimageContents}/wechat.png -t $out/share/pixmaps
substituteInPlace $out/share/applications/wechat.desktop \
--replace-fail 'Exec=AppRun' 'Exec=${pname}'
'';
};
darwin = stdenv.mkDerivation {
inherit pname src meta;
version = "4.0.0.5";
nativeBuildInputs = [ undmg ];
sourceRoot = ".";
installPhase = ''
runHook preInstall
mkdir -p $out/Applications
cp -r *.app $out/Applications
runHook postInstall
'';
};
in
if stdenv.hostPlatform.isDarwin then darwin else linux