From 4b4736f6eb1305723826fb1494af16e94026156f Mon Sep 17 00:00:00 2001 From: Noa Aarts Date: Fri, 22 Nov 2024 20:19:45 +0100 Subject: [PATCH] use services for automapaper --- common/home.nix | 64 +++++++++++++++++++++++++++++++ packages/niri-config/default.nix | 47 ----------------------- packages/niri-config/template.kdl | 1 - 3 files changed, 64 insertions(+), 48 deletions(-) diff --git a/common/home.nix b/common/home.nix index f7de148..5446ee1 100644 --- a/common/home.nix +++ b/common/home.nix @@ -154,6 +154,70 @@ in }; }; + systemd.user = { + enable = enableGraphical; + + services = builtins.listToAttrs ( + builtins.map ( + { + name, + horizontal, + vertical, + ... + }: + let + display_config = + let + display-shader = pkgs.substituteAll { + src = ../modules/automapaper/display-with_vars.glsl; + background = inputs.nix-colors.lib.conversions.hexToGLSLVec "0a000a"; + foreground = inputs.nix-colors.lib.conversions.hexToGLSLVec "192291"; + }; + state-shader = ../modules/automapaper/state-game_of_life.glsl; + init-shader = ../modules/automapaper/init.glsl; + # General configurations + cycles = 2000; + tps = 30; + horizontal-dot-size = 10; + vertical-dot-size = 10; + in + (import ../modules/automapaper/config.nix { + inherit (pkgs) writeTextFile; + inherit + init-shader + state-shader + display-shader + tps + cycles + ; + display = name; + horizontal = builtins.div horizontal horizontal-dot-size; + vertical = builtins.div vertical vertical-dot-size; + }); + + in + lib.attrsets.nameValuePair "automapaper-${name}" ({ + Install = { + WantedBy = [ "niri.service" ]; + }; + Unit = { + Description = "Automapaper for display ${name}"; + PartOf = "graphical-session.target"; + After = "graphical-session.target"; + Requisite = "graphical-session.target"; + }; + + Service = { + ExecStart = "${ + inputs.automapaper.packages.${pkgs.system}.automapaper + }/bin/automapaper -C ${display_config}/config.toml"; + Restart = "on-failure"; + }; + }) + ) displays + ); + }; + xdg = { enable = true; userDirs = { diff --git a/packages/niri-config/default.nix b/packages/niri-config/default.nix index 7758b01..755438d 100644 --- a/packages/niri-config/default.nix +++ b/packages/niri-config/default.nix @@ -9,56 +9,10 @@ let launcher = "${self-pkgs.fuzzel-launch}/bin/fuzzel-launch"; power-menu = "${self-pkgs.fuzzel-power}/bin/fuzzel-power"; lockscreen = "${pkgs.swaylock}/bin/swaylock"; - wallpapers = - let - automapaper-configs = builtins.map ( - { - name, - horizontal, - vertical, - ... - }: - let - display-shader = pkgs.substituteAll { - src = ../../modules/automapaper/display-with_vars.glsl; - background = inputs.nix-colors.lib.conversions.hexToGLSLVec "101012"; - foreground = inputs.nix-colors.lib.conversions.hexToGLSLVec "192291"; - }; - state-shader = ../../modules/automapaper/state-game_of_life.glsl; - init-shader = ../../modules/automapaper/init.glsl; - - # General configurations - cycles = 2000; - tps = 30; - horizontal-dot-size = 10; - vertical-dot-size = 10; - in - (import ../../modules/automapaper/config.nix { - inherit (pkgs) writeTextFile; - inherit - init-shader - state-shader - display-shader - tps - cycles - ; - display = name; - horizontal = builtins.div horizontal horizontal-dot-size; - vertical = builtins.div vertical vertical-dot-size; - }) - ) displays; - in - pkgs.lib.strings.concatMapStringsSep "\n" ( - file: - ''spawn-at-startup "${ - inputs.automapaper.packages.${pkgs.system}.automapaper - }/bin/automapaper" "-C" "${file}/config.toml"'' - ) automapaper-configs; autostart-string = "spawn-at-startup \"" + pkgs.lib.strings.concatStringsSep "\nspawn-at-startup \"" [ "${pkgs.dunst}/bin/dunst\"" - "${pkgs.xwayland-satellite}/bin/xwayland-satellite\"" "spotify\"" "keepassxc\"" "thunderbird\"" @@ -91,7 +45,6 @@ pkgs.substituteAll { launcher = launcher; power_menu = power-menu; lockscreen = lockscreen; - wallpapers = wallpapers; displays = displays-string; autostart = autostart-string; diff --git a/packages/niri-config/template.kdl b/packages/niri-config/template.kdl index 887fc3d..d3867e1 100644 --- a/packages/niri-config/template.kdl +++ b/packages/niri-config/template.kdl @@ -119,7 +119,6 @@ layout { // which may be more convenient to use. // See the binds section below for more spawn examples. // spawn-at-startup "alacritty" "-e" "fish" -@wallpapers@ @autostart@