From 2aa3d272c97d25318a90bdab2dc1e94840aca4b5 Mon Sep 17 00:00:00 2001 From: muon Date: Fri, 14 Jun 2024 15:54:47 +0000 Subject: [PATCH] Setup monitors --- hosts/muon/configuration.nix | 56 ++++++++++++++++++++++------------ hosts/muon/home.nix | 16 +++++----- modules/nixos/core/boot.nix | 2 +- modules/nixos/desktop/xorg.nix | 24 +++++++++++---- 4 files changed, 63 insertions(+), 35 deletions(-) diff --git a/hosts/muon/configuration.nix b/hosts/muon/configuration.nix index b5e2032..3e86208 100644 --- a/hosts/muon/configuration.nix +++ b/hosts/muon/configuration.nix @@ -42,25 +42,43 @@ in { services.xserver.libinput.mouse.accelProfile = "flat"; ## Monitors - mods.monitor.main.resolution = res; - services.xserver.xrandrHeads = [ - { - output = "DP-2"; - primary = true; - monitorConfig = '' - Option "PreferredMode" "${res}" - Option "Position" "0x480" - ''; - } - { - output = "HDMI-1"; - monitorConfig = '' - Option "PreferredMode" "1920x1080" - Option "Position" "2560x-480" - Option "Rotate" "right" - ''; - } - ]; + mods.monitors = { + primary = { + name = "DP-2"; + config = { + enable = true; + mode = res; + position = "0x480"; + primary = true; + rate = "144.00"; + }; + }; + secondary = { + name = "HDMI-1"; + config = { + enable = true; + mode = "1920x1080"; + position = "2560x0"; + rate = "60.00"; + rotate = "right"; + }; + }; + }; + services.autorandr = { + enable = true; + profiles."${config.mods.user.name}" = { + fingerprint = { + "${config.mods.monitors.primary.name}" = "00ffffffffffff000469a827528b01002f1a0104a53c22783ba595a65650a0260d5054bfef00714f95008180d1c00101010101010101e8e40050a0a067500820980455502100001e565e00a0a0a029503020350055502100001e000000fd002890dede3c010a202020202020000000fc0041535553204d473237380a202001cd02031e714b1213041f900e0f1d1e0514230917078301000065030c001000e8e40050a0a067500820980455502100001e909b0050a0a046500820880c55502100001e662156aa51001e30468f330055502100001e565e00a0a0a029503020350055502100001e87bc0050a0a055500820780055502100001e0000000000000056"; + "${config.mods.monitors.secondary.name}" = "00ffffffffffff00410c00000101010107160103804024780af9aba2554a9a250f474a21080081800101010101010101010101010101023a801871382d40582c450080682100001e1b2150a051001e3048883500806821000018000000fc005048494c495053204654560a20000000fd00384c1e5311000a20202020202001ca020326714e9f10202122140513041102150601260907031507508301000067030c001000b82d023a80d072382d40102c458080682100001e011d803e73382d407e2c458080682100001e011d80d0721c1620102c258080682100009e011d00bc52d01e20b828554080682100001e00000000000000000000000000000000002c"; + }; + config = { + "${config.mods.monitors.primary.name}" = + config.mods.monitors.primary.config; + "${config.mods.monitors.secondary.name}" = + config.mods.monitors.secondary.config; + }; + }; + }; # Backup environment services.xserver.windowManager.qtile.enable = true; diff --git a/hosts/muon/home.nix b/hosts/muon/home.nix index 2870d10..b3d69bc 100644 --- a/hosts/muon/home.nix +++ b/hosts/muon/home.nix @@ -19,15 +19,13 @@ let cfg = osConfig.mods; in { # Host specific ## Monitors - xsession.windowManager.i3.config.workspaceOutputAssign = [ - { - workspace = "1"; - output = "DP-2"; - } { - workspace = "2"; - output = "HDMI-1"; - } - ]; + xsession.windowManager.i3.config.workspaceOutputAssign = [{ + workspace = "1"; + output = "${osConfig.mods.monitors.primary.name}"; + } { + workspace = "2"; + output = "${osConfig.mods.monitors.secondary.name}"; + }]; wayland.windowManager.hyprland.settings = { monitor = [ diff --git a/modules/nixos/core/boot.nix b/modules/nixos/core/boot.nix index b533690..67abbec 100644 --- a/modules/nixos/core/boot.nix +++ b/modules/nixos/core/boot.nix @@ -9,7 +9,7 @@ enable = true; efiSupport = true; device = "nodev"; - gfxmodeEfi = config.mods.monitor.main.resolution; + gfxmodeEfi = config.mods.monitors.primary.config.mode; }; }; } diff --git a/modules/nixos/desktop/xorg.nix b/modules/nixos/desktop/xorg.nix index e1de840..f25e0cd 100644 --- a/modules/nixos/desktop/xorg.nix +++ b/modules/nixos/desktop/xorg.nix @@ -1,11 +1,23 @@ -{ pkgs, lib, config, ... }: { +{ pkgs, lib, config, ... }: let + monitorModule = lib.types.submodule { + options = { + name = lib.mkOption { + type = lib.types.string; + description = "monitor name"; + example = "HDMI-1"; + }; + config = lib.mkOption { + type = lib.types.attrs; + description = "autorandr profile config"; + }; + }; + }; +in { options.mods = { xorg.enable = lib.mkEnableOption "enables xorg"; - monitor.main.resolution = lib.mkOption { - description = "main monitor resolution"; - type = lib.types.string; - default = "1920x1080"; - example = "2560x1440"; + monitors = lib.mkOption { + type = lib.types.attrsOf monitorModule; + default = { }; }; };