use services for automapaper

This commit is contained in:
Noa Aarts 2024-11-22 20:19:45 +01:00
parent 0050156bde
commit 4b4736f6eb
Signed by: noa
GPG key ID: 1850932741EFF672
3 changed files with 64 additions and 48 deletions

View file

@ -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 = { xdg = {
enable = true; enable = true;
userDirs = { userDirs = {

View file

@ -9,56 +9,10 @@ let
launcher = "${self-pkgs.fuzzel-launch}/bin/fuzzel-launch"; launcher = "${self-pkgs.fuzzel-launch}/bin/fuzzel-launch";
power-menu = "${self-pkgs.fuzzel-power}/bin/fuzzel-power"; power-menu = "${self-pkgs.fuzzel-power}/bin/fuzzel-power";
lockscreen = "${pkgs.swaylock}/bin/swaylock"; 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 = autostart-string =
"spawn-at-startup \"" "spawn-at-startup \""
+ pkgs.lib.strings.concatStringsSep "\nspawn-at-startup \"" [ + pkgs.lib.strings.concatStringsSep "\nspawn-at-startup \"" [
"${pkgs.dunst}/bin/dunst\"" "${pkgs.dunst}/bin/dunst\""
"${pkgs.xwayland-satellite}/bin/xwayland-satellite\""
"spotify\"" "spotify\""
"keepassxc\"" "keepassxc\""
"thunderbird\"" "thunderbird\""
@ -91,7 +45,6 @@ pkgs.substituteAll {
launcher = launcher; launcher = launcher;
power_menu = power-menu; power_menu = power-menu;
lockscreen = lockscreen; lockscreen = lockscreen;
wallpapers = wallpapers;
displays = displays-string; displays = displays-string;
autostart = autostart-string; autostart = autostart-string;

View file

@ -119,7 +119,6 @@ layout {
// which may be more convenient to use. // which may be more convenient to use.
// See the binds section below for more spawn examples. // See the binds section below for more spawn examples.
// spawn-at-startup "alacritty" "-e" "fish" // spawn-at-startup "alacritty" "-e" "fish"
@wallpapers@
@autostart@ @autostart@