refactor(niri): base niri.outputs on config.monitors

This commit is contained in:
Nickolaj Jepsen 2025-08-23 18:42:54 +02:00
parent ba100b98ba
commit 1bed4d5d9f
10 changed files with 133 additions and 119 deletions

View file

@ -101,16 +101,13 @@ in {
else "";
resolution =
if m.resolution != null
then m.resolution
then "${builtins.toString m.resolution.width}x${builtins.toString m.resolution.height}"
else "preferred";
refreshRate =
if m.refreshRate != null
then "@${builtins.toString m.refreshRate}"
else "";
position =
if m.position != null
then m.position
else "auto";
position = "${builtins.toString m.position.x}x${builtins.toString m.position.y}";
transform =
if m.transform != null
then ", transform, ${builtins.toString m.transform}"

View file

@ -1,8 +1,12 @@
{
pkgs,
inputs,
config,
lib,
...
}: {
}: let
primaryMonitorName = (builtins.head config.monitors).name or "";
in {
# TODO: Move these to a separate module
fireproof.home-manager.programs.waybar = {
enable = true;
@ -145,21 +149,21 @@
}
];
workspaces = {
workspaces = lib.mkIf (primaryMonitorName != "") {
"01" = {
open-on-output = "DP-5";
open-on-output = primaryMonitorName;
};
"02" = {
open-on-output = "DP-5";
open-on-output = primaryMonitorName;
};
"03" = {
open-on-output = "DP-5";
open-on-output = primaryMonitorName;
};
"04" = {
open-on-output = "DP-5";
open-on-output = primaryMonitorName;
};
"05" = {
open-on-output = "DP-5";
open-on-output = primaryMonitorName;
};
};
@ -280,5 +284,25 @@
"Mod+Space".action.spawn = ["fuzzel"];
"Mod+Backspace".action.close-window = {};
};
outputs = lib.mkIf (config.monitors != []) (
lib.listToAttrs (map (monitor: let
refreshRateFloat = lib.mkIf (monitor.refreshRate != null) (builtins.fromJSON "${builtins.toString monitor.refreshRate}.0");
in {
inherit (monitor) name;
value = {
inherit (monitor) position;
mode = {
inherit (monitor.resolution) width height;
refresh = refreshRateFloat;
};
transform.rotation =
if (monitor.transform != null)
then monitor.transform * 90
else 0;
};
})
config.monitors)
);
};
}

View file

@ -1,11 +1,14 @@
{pkgs, lib, ...}: let
{
pkgs,
lib,
...
}: let
screenshotPkg = pkgs.writeShellScriptBin "screenshot" ''
AREA=$(${lib.getExe pkgs.slurp} -d)
${lib.getExe pkgs.grim} -t ppm -g "$AREA" - | ${lib.getExe pkgs.satty} -f - --initial-tool=arrow --copy-command=${pkgs.wl-clipboard}/bin/wl-copy --action-on-enter="save-to-clipboard" --disable-notifications
'';
in {
in {
environment.systemPackages = [
screenshotPkg
];
}
}