automapaper?

This commit is contained in:
Noa Aarts 2024-11-19 00:21:05 +01:00
parent 77d730d177
commit ad2cafa469
Signed by: noa
GPG key ID: 1850932741EFF672
3 changed files with 74 additions and 60 deletions

View file

@ -120,6 +120,7 @@ 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"
@automapaper@
// Uncomment this line to ask the clients to omit their client-side decorations if possible. // Uncomment this line to ask the clients to omit their client-side decorations if possible.
// If the client will specifically ask for CSD, the request will be honored. // If the client will specifically ask for CSD, the request will be honored.

View file

@ -92,23 +92,33 @@
scale = "1"; scale = "1";
} }
]; ];
extraConfig = { extraConfig =
xdg.configFile = let
let hconfig = config.home-manager.users.noa;
wpkgs = inputs.self.packages.${pkgs.system}; in
in {
{ xdg.configFile =
"niri/config.kdl".source = pkgs.substituteAll { let
src = ../../extra/niri.kdl; wpkgs = inputs.self.packages.${pkgs.system};
env = { in
kitty = "${pkgs.kitty}/bin/kitty"; {
wofilaunch = "${wpkgs.wofi-launch}/bin/wofi-launch"; "niri/config.kdl".source = pkgs.substituteAll {
wofipower = "${wpkgs.wofi-power}/bin/wofi-power"; src = ../../extra/niri.kdl;
swaylock = "${pkgs.swaylock}/bin/swaylock"; env = {
kitty = "${pkgs.kitty}/bin/kitty";
wofilaunch = "${wpkgs.wofi-launch}/bin/wofi-launch";
wofipower = "${wpkgs.wofi-power}/bin/wofi-power";
swaylock = "${pkgs.swaylock}/bin/swaylock";
automapaper = lib.strings.concatMapStringsSep "\n" (
command:
(
''spawn-at-startup "${(lib.strings.concatStringsSep ''" "'' (lib.strings.splitString " " command))}"''
)
) hconfig.modules.automapaper.startStrings;
};
}; };
}; };
}; };
};
}; };
"root" = import ./root.nix; "root" = import ./root.nix;
}; };

View file

@ -13,6 +13,9 @@ in
options.modules.automapaper = { options.modules.automapaper = {
enable = lib.mkEnableOption "enable automapaper"; enable = lib.mkEnableOption "enable automapaper";
hyprland = lib.mkEnableOption "enable hyprland exec-once integration"; hyprland = lib.mkEnableOption "enable hyprland exec-once integration";
startStrings = lib.mkOption {
type = lib.types.listOf lib.types.str;
};
default-configuration = { default-configuration = {
init = lib.mkOption { init = lib.mkOption {
type = lib.types.str; type = lib.types.str;
@ -142,49 +145,49 @@ in
}; };
}; };
config = lib.mkIf cfg.enable { config =
wayland.windowManager.hyprland.settings.exec-once = let
let mkDisplayConfig =
mkDisplayConfig = conf:
conf: let
let init = builtins.toFile "init.frag" conf.init;
init = builtins.toFile "init.frag" conf.init; state = builtins.toFile "state.frag" conf.state;
state = builtins.toFile "state.frag" conf.state; display = builtins.toFile "display.frag" conf.display;
display = builtins.toFile "display.frag" conf.display; in
in ''
'' [display]
[display] name="${conf.name}"
name="${conf.name}" horizontal=${builtins.toString conf.horizontal}
horizontal=${builtins.toString conf.horizontal} vertical=${builtins.toString conf.vertical}
vertical=${builtins.toString conf.vertical} tps=${builtins.toString conf.tps}
tps=${builtins.toString conf.tps} state_frag="${state}"
state_frag="${state}" init_frag="${init}"
init_frag="${init}" display_frag="${display}"
display_frag="${display}" cycles=${builtins.toString conf.cycles}
cycles=${builtins.toString conf.cycles} frames_per_tick=${builtins.toString conf.frames_per_tick}
frames_per_tick=${builtins.toString conf.frames_per_tick} '';
''; confFile =
confFile = let
let def = config.modules.automapaper.default-configuration;
def = config.modules.automapaper.default-configuration; in
in conf:
conf: builtins.toFile "${conf.name}.toml" (mkDisplayConfig {
builtins.toFile "${conf.name}.toml" (mkDisplayConfig { name = conf.name;
name = conf.name; horizontal = builtins.div conf.horizontal def.horizontal;
horizontal = builtins.div conf.horizontal def.horizontal; vertical = builtins.div conf.vertical def.vertical;
vertical = builtins.div conf.vertical def.vertical; tps = def.tps;
tps = def.tps; state = def.state;
state = def.state; init = def.init;
init = def.init; display = def.display;
display = def.display; cycles = def.cycles;
cycles = def.cycles; frames_per_tick = def.frames_per_tick;
frames_per_tick = def.frames_per_tick; });
}); in
in lib.mkIf cfg.enable rec {
lib.mkIf cfg.hyprland ( modules.automapaper.startStrings = builtins.map (
builtins.map ( conf: "${inputs.automapaper.packages.${pkgs.system}.default}/bin/automapaper -C ${confFile conf}"
conf: "${inputs.automapaper.packages.${pkgs.system}.default}/bin/automapaper -C ${confFile conf}" ) config.modules.hyprland.displays;
) config.modules.hyprland.displays
); wayland.windowManager.hyprland.settings.exec-once = lib.mkIf cfg.hyprland modules.automapaper.startStrings;
}; };
} }