monitor crimes
This commit is contained in:
parent
bf89ee073a
commit
97110919cd
2 changed files with 49 additions and 15 deletions
|
|
@ -1,33 +1,64 @@
|
|||
{ lib, config, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
with lib.my;
|
||||
let
|
||||
cfg = config.modules.desktop.monitors;
|
||||
in {
|
||||
options.modules.desktop.monitors = {
|
||||
enable = mkEnableOption "manually configure monitor settings, use if manual configuration is needed";
|
||||
monitors = mkOption {
|
||||
type = types.listOf types.attrs;
|
||||
description = ''
|
||||
a list of monitor configurations. each entry should be an attribute set with the following keys:
|
||||
- `name`: The name of the monitor to configure
|
||||
- `scale`: The scale factor to apply to the monitor
|
||||
- `vrr`?: Whether or not the display supports variable refresh rate. Defaults to false
|
||||
note: the first monitor in the list will be considered the "primary" monitor
|
||||
'';
|
||||
type = types.listOf (types.submodule {
|
||||
options = {
|
||||
name = mkOption {
|
||||
type = types.str;
|
||||
description = "the monitor name to configure. easily fetchable from `niri msg outputs`";
|
||||
example = "eDP-1";
|
||||
};
|
||||
scale = mkOpt (types.nullOr types.float) 1.0;
|
||||
vrr = mkEnableOption "whether or not to enable VRR (variable refresh rate)";
|
||||
primary = mkEnableOption "whether or not the monitor is the primary monitor";
|
||||
resolution = mkOpt (types.nullOr (types.submodule {
|
||||
options = {
|
||||
width = mkOption { type = types.int; };
|
||||
height = mkOption { type = types.int; };
|
||||
};
|
||||
})) null;
|
||||
position = mkOpt (types.nullOr (types.submodule {
|
||||
options = {
|
||||
x = mkOption { type = types.int; };
|
||||
y = mkOption { type = types.int; };
|
||||
};
|
||||
})) null;
|
||||
};
|
||||
});
|
||||
example = [
|
||||
{ name = "eDP-1"; scale = 2.0; }
|
||||
{ name = "HDMI-1"; scale = 1.0; }
|
||||
{ name = "eDP-1"; scale = 2.0; primary = true; }
|
||||
{ name = "HDMI-1"; scale = 1.0; vrr = true; }
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
assertions = [
|
||||
{
|
||||
assertion = builtins.length (builtins.filter (m: m.primary) cfg.monitors) <= 1;
|
||||
message = "only one monitor should be marked as primary";
|
||||
}
|
||||
];
|
||||
|
||||
hm.programs.niri.settings.outputs = builtins.listToAttrs (builtins.map (monitor: {
|
||||
name = monitor.name;
|
||||
value = {
|
||||
scale = monitor.scale;
|
||||
variable-refresh-rate = monitor.vrr or false;
|
||||
variable-refresh-rate = monitor.vrr;
|
||||
focus-at-startup = monitor.primary;
|
||||
position = monitor.position;
|
||||
} // optionalAttrs (monitor.resolution != null) {
|
||||
mode = {
|
||||
width = monitor.resolution.width;
|
||||
height = monitor.resolution.height;
|
||||
};
|
||||
};
|
||||
}) cfg.monitors);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue