From a996b8890e88f20e98e455825e6421093eb2f6ed Mon Sep 17 00:00:00 2001 From: Noa Aarts Date: Sat, 2 Mar 2024 00:25:38 +0100 Subject: [PATCH] add wallpaper :) --- common/automapaper/automapaper.nix | 15 ++++++++ common/automapaper/config.toml | 24 +++++++++++++ common/automapaper/config2nd.toml | 23 ++++++++++++ common/automapaper/display.frag | 29 +++++++++++++++ common/automapaper/init.frag | 23 ++++++++++++ common/automapaper/state.frag | 35 ++++++++++++++++++ common/hyprland.nix | 3 ++ custom/automapaper/default.nix | 57 ++++++++++++++++++++++++++++++ hosts/default/home.nix | 7 ++++ 9 files changed, 216 insertions(+) create mode 100644 common/automapaper/automapaper.nix create mode 100644 common/automapaper/config.toml create mode 100644 common/automapaper/config2nd.toml create mode 100644 common/automapaper/display.frag create mode 100644 common/automapaper/init.frag create mode 100644 common/automapaper/state.frag create mode 100644 custom/automapaper/default.nix diff --git a/common/automapaper/automapaper.nix b/common/automapaper/automapaper.nix new file mode 100644 index 0000000..2648958 --- /dev/null +++ b/common/automapaper/automapaper.nix @@ -0,0 +1,15 @@ +{ config, pkgs, inputs, ... }: + +{ + home.packages = with pkgs; [ + (callPackage ../../custom/automapaper/default.nix { }) + ]; + + home.file = { + "${config.xdg.configHome}/automapaper/config.toml".source = ./config.toml; + "${config.xdg.configHome}/automapaper/config2nd.toml".source = ./config2nd.toml; + "${config.xdg.configHome}/automapaper/state.frag".source = ./state.frag; + "${config.xdg.configHome}/automapaper/init.frag".source = ./init.frag; + "${config.xdg.configHome}/automapaper/display.frag".source = ./display.frag; + }; +} diff --git a/common/automapaper/config.toml b/common/automapaper/config.toml new file mode 100644 index 0000000..c16c5af --- /dev/null +++ b/common/automapaper/config.toml @@ -0,0 +1,24 @@ +# this is the config for Automapaper +# you need one for each display you want the wallpaper on +[display] +# name of the display in wayland +name="DP-3" +# the horizontal cell amount to simulate +horizontal=256 +# the vertical cell amount to simulate +vertical=144 +# target simulation ticks per second +tps=30 +# automaton shader +# this has access to the previous state, which is a (horizontal, vertical) sized texture2D that uses rgba float values +state_frag="/home/noa/.config/automapaper/state.frag" +# initial state / reset shader +# this has access to the resolution, and the time since the program was started +init_frag="/home/noa/.config/automapaper/init.frag" +# scaling/display shader +# this has access to the current and previous state to display +display_frag="/home/noa/.config/automapaper/display.frag" +# the amount of cycles before the init_frag shader reruns +cycles=2500 +# the amount of frames to display per state tick +frames_per_tick=1 diff --git a/common/automapaper/config2nd.toml b/common/automapaper/config2nd.toml new file mode 100644 index 0000000..f330d74 --- /dev/null +++ b/common/automapaper/config2nd.toml @@ -0,0 +1,23 @@ +# this is the config for Automapaper +[display] +# name of the display in wayland +name = "DP-2" +# the horizontal cell amount to simulate +horizontal = 192 +# the vertical cell amount to simulate +vertical = 108 +# target simulation ticks per second +tps = 20 +# automaton shader +# this has access to the previous state, which is a (horizontal, vertical) sized texture2D that uses the rgba values +state_frag="/home/noa/.config/automapaper/state.frag" +# initial state / reset shader +# this has access to the resolution, and the time since the program was started +init_frag="/home/noa/.config/automapaper/init.frag" +# scaling/display shader +# this has access to the current and previous state to display +display_frag="/home/noa/.config/automapaper/display.frag" +# the amount of cycles before the init_frag shader reruns +cycles = 2500 +# the amount of frames to display per state tick +frames_per_tick = 1 diff --git a/common/automapaper/display.frag b/common/automapaper/display.frag new file mode 100644 index 0000000..6ea2349 --- /dev/null +++ b/common/automapaper/display.frag @@ -0,0 +1,29 @@ +#version 310 es +precision highp float; + +uniform sampler2D tex2D; +uniform sampler2D old2D; +uniform ivec2 resolution; +uniform float frame_part; + +in highp vec2 texCoords; +out vec4 stateColor; + +const vec4 bgColor = vec4(0.15, 0.02, 0.18, 1.0); +const vec4 fgColor = vec4(0.58, 0.06, 0.68, 1.0); + +void main() { + vec2 canvasSize = vec2(textureSize(tex2D, 0)); + vec4 state = texture(tex2D, texCoords); + vec4 ostate = texture(old2D, texCoords); + + vec2 localCoords = fract(gl_FragCoord.xy / vec2(resolution) * canvasSize); + localCoords = localCoords - 0.5; + float dist = sqrt(dot(localCoords, localCoords)); + + float size = smoothstep(0.0, 1.0, pow(mix(ostate.g,state.g, frame_part), 3.0)) * 0.35; + float mask = 1.0 - step(size, dist); + + float brightness = mix(ostate.r,state.r, frame_part) + 0.2 * pow(mix(ostate.g,state.g, frame_part), 3.0); + stateColor = mix(bgColor, fgColor, brightness * mask); +} diff --git a/common/automapaper/init.frag b/common/automapaper/init.frag new file mode 100644 index 0000000..3ac9c5b --- /dev/null +++ b/common/automapaper/init.frag @@ -0,0 +1,23 @@ +#version 310 es +precision highp float; + +uniform float time; +uniform vec2 resolution; + +out vec4 stateColor; + +float PHI = 1.61803398874989484820459; // Φ = Golden Ratio + +float gold_noise(in vec2 xy, in float seed){ + return fract(tan(distance(xy*PHI, xy)*seed)*xy.x); +} + +void main( void ) { + + vec2 position = gl_FragCoord.xy; + float color = gold_noise(position.xy, fract(time)); + + + stateColor = vec4(step(0.3, color), 0,0,step(0.3, color)); +} + diff --git a/common/automapaper/state.frag b/common/automapaper/state.frag new file mode 100644 index 0000000..1c04e66 --- /dev/null +++ b/common/automapaper/state.frag @@ -0,0 +1,35 @@ +#version 310 es +precision highp float; + +uniform sampler2D state; +uniform vec2 scale; + +out vec4 stateColor; + +vec4 get(int x, int y) { + return texture(state, (gl_FragCoord.xy + vec2(x, y)) / scale); +} + +void main() { + int sum = int(get(-1, -1).r + + get(-1, 0).r + + get(-1, 1).r + + get( 0, -1).r + + get( 0, 1).r + + get( 1, -1).r + + get( 1, 0).r + + get( 1, 1).r); + vec4 current = get(0,0); + if (sum == 3) { + stateColor.r = 1.0; + stateColor.g = 1.0; + } else if (sum == 2) { + stateColor = current; + if (current.r == 0.0) { + stateColor.g = max(current.g - 0.01, 0.0); + } + } else { + stateColor = vec4(0.0, max(current.g - 0.01, 0.0), 0.0, 1.0); + } + +} diff --git a/common/hyprland.nix b/common/hyprland.nix index e7c7098..beefcb9 100644 --- a/common/hyprland.nix +++ b/common/hyprland.nix @@ -34,6 +34,9 @@ exec-once = [ "waybar" "dunst" + "automapaper -C ${config.xdg.configHome}/automapaper/config.toml" + "automapaper -C ${config.xdg.configHome}/automapaper/config2nd.toml" + "hyprctl dispatcher focusmonitor 1" ]; general = { sensitivity = "1.2"; diff --git a/custom/automapaper/default.nix b/custom/automapaper/default.nix new file mode 100644 index 0000000..b640ad1 --- /dev/null +++ b/custom/automapaper/default.nix @@ -0,0 +1,57 @@ +{ + lib + , stdenv + , fetchgit + , meson + , ninja + , pkg-config + , pacman + , libarchive + , wayland + , libGL +}: + +stdenv.mkDerivation rec { + pname = "automapaper"; + version = "unstable-2022-05-15"; + + src = fetchgit { + url = "https://github.com/itepastra/automapaper"; + rev = "f102526244d954a4e4ae30a4b11f070e821f66ec"; + sha256 = "sha256-IS9vqSmDbiLwLwUeIxxPI2t7yksxvACgiECeSV43Wug="; + }; + + meta = with lib; { + description = "based animated wallpaper for wlroots"; + homepage = "https://github.com/itepastra/automapaper"; + license = licenses.gpl3Plus; + platforms = platforms.linux; + maintainers = with maintainers; [ itepastra ]; + }; + + nativeBuildInputs = [ + meson + ninja + pkg-config + pacman + libarchive + ]; + buildInputs = [ + wayland + libGL + ]; + + configurePhase = '' + meson setup build + ''; + + + buildPhase = '' + ninja -C build + ''; + + installPhase = '' + mkdir -p $out/bin + mv build/automapaper $out/bin + ''; +} diff --git a/hosts/default/home.nix b/hosts/default/home.nix index d1be72b..4bf42ec 100644 --- a/hosts/default/home.nix +++ b/hosts/default/home.nix @@ -10,6 +10,7 @@ ../../common/nvim/nvim.nix ../../common/discord.nix ../../common/spotify.nix + ../../common/automapaper/automapaper.nix ]; # Home Manager needs a bit of information about you and the paths it should # manage. @@ -84,11 +85,17 @@ # # /etc/profiles/per-user/noa/etc/profile.d/hm-session-vars.sh # + + home.sessionVariables = { EDITOR = "nvim"; TERM = "kitty"; }; + xdg = { + enable = true; + }; + xdg.userDirs = { enable = true; createDirectories = true;