monitors.nix: added monitor config via modules

This commit is contained in:
Charlie Root 2024-08-28 11:04:53 +02:00
commit 4a2f1302d8
6 changed files with 102 additions and 72 deletions

View file

@ -3,5 +3,6 @@ _: {
./configuration.nix ./configuration.nix
./programs.nix ./programs.nix
./hardware-configuration.nix ./hardware-configuration.nix
./hardware
]; ];
} }

View file

@ -0,0 +1 @@
_: {imports = [./monitors.nix];}

View file

View file

@ -0,0 +1,18 @@
_: {
modules.system.hardware.monitors = [
{
name = "Integrated laptop screen";
device = "eDP-1";
resolution = {
x = 1920;
y = 1080;
};
scale = 1;
refresh_rate = 60;
position = {
x = 0;
y = 0;
};
}
];
}

View file

@ -1,71 +1,73 @@
{lib, ...}: {lib, ...}: let
with lib; { inherit (lib) mkOption;
options.modules.other.system.monitors = mkOption { inherit (lib.types) str submodule int ints number listOf;
in {
options.modules.system.monitors = mkOption {
description = "\n List of monitors to use\n "; description = "\n List of monitors to use\n ";
default = []; default = [];
type = with types; type = listOf (submodule {
types.listOf (submodule { options = {
options = { name = mkOption {
name = mkOption { type = str;
type = types.str; description = "Give your monitor a cute name";
description = "Give your monitor a cute name"; default = "";
default = "monitor0(I am lazy)"; };
}; device = mkOption {
device = mkOption { type = str;
type = types.str; description = "The actual device name of the monitor";
description = "The actual device name of the monitor"; default = "eDP-1";
}; };
resolution = mkOption { resolution = mkOption {
type = types.submodule { type = submodule {
options = { options = {
x = mkOption { x = mkOption {
type = types.int; type = int;
description = "monitor width"; description = "monitor width";
default = "1920"; default = "1920";
}; };
y = mkOption { y = mkOption {
type = types.int; type = int;
description = "monitor height"; description = "monitor height";
default = "1080"; default = "1080";
};
}; };
}; };
}; };
scale = mkOption {
type = types.number;
description = "monitor scale";
default = 1.0;
};
refresh_rate = mkOption {
type = types.int;
description = "monitor refresh rate (in Hz)";
default = 60;
};
position = mkOption {
type = types.submodule {
options = {
x = mkOption {
type = types.int;
default = 0;
};
y = mkOption {
type = types.int;
default = 0;
};
};
};
description = "absolute monitor posititon";
default = {
x = 0;
y = 0;
};
};
transform = mkOption {
type = types.ints.between 0 3;
description = "Rotation of the monitor counterclockwise";
default = 0;
};
}; };
}); scale = mkOption {
type = number;
description = "monitor scale";
default = 1.0;
};
refresh_rate = mkOption {
type = int;
description = "monitor refresh rate (in Hz)";
default = 60;
};
position = mkOption {
type = submodule {
options = {
x = mkOption {
type = int;
default = 0;
};
y = mkOption {
type = int;
default = 0;
};
};
};
description = "absolute monitor posititon";
default = {
x = 0;
y = 0;
};
};
transform = mkOption {
type = ints.between 0 3;
description = "Rotation of the monitor counterclockwise";
default = 0;
};
};
});
}; };
} }

View file

@ -8,6 +8,7 @@
cfg = config.modules.usrEnv.desktops.hyprland; cfg = config.modules.usrEnv.desktops.hyprland;
inherit (config.modules.other.system) username; inherit (config.modules.other.system) username;
inherit (config.modules.style) cursor; inherit (config.modules.style) cursor;
inherit (config.modules.hardware) monitors;
inherit inherit
(inputs'.split-monitor-workspaces.packages) (inputs'.split-monitor-workspaces.packages)
@ -58,14 +59,21 @@ in {
"$mainMod" = "SUPER"; "$mainMod" = "SUPER";
# Monitor config # Monitor config
monitor = [ # monitor = [
"eDP-1,1920x1080,0x0,1" # "eDP-1,1920x1080,0x0,1"
# "DP-2,1920x1080,0x0,1" # # "DP-2,1920x1080,0x0,1"
# "HDMI-A-2,1920x1080,1920x0,1" # # "HDMI-A-2,1920x1080,1920x0,1"
# "HDMI-A-1,1920x1080,3840x0,1" # # "HDMI-A-1,1920x1080,3840x0,1"
# Had the shadow monitor bug, so had to disable all unknown monitors. # # Had the shadow monitor bug, so had to disable all unknown monitors.
"Unknown-1,disable" # "Unknown-1,disable"
]; # ];
monitor =
map (
m: "${m.device},${toString m.resolution.x}x${toString m.resolution.y}@${toString m.refresh_rate},${toString m.position.x}x${toString m.position.y},${toString m.scale},transform,${toString m.transform}"
)
monitors; #TODO: default value
# Workspace config # Workspace config
workspace = [ workspace = [
"1,monitor:eDP-1, default:true" "1,monitor:eDP-1, default:true"
@ -163,7 +171,7 @@ in {
]; ];
# Hyprland anomations, using the above bezier curves # Hyprland anomations, using the above bezier curves
animations = { animations = {
enabled = true; enabled = false;
animation = [ animation = [
"windows, 1, 4, dupa, popin" "windows, 1, 4, dupa, popin"
"windowsOut, 1, 4, dupa, slide" "windowsOut, 1, 4, dupa, slide"