feat: use per device monitor configuration

This commit is contained in:
Nydragon 2024-11-29 10:58:20 +01:00
parent cb0744c298
commit f2f778891c
Signed by: nydragon
SSH key fingerprint: SHA256:WcjW5NJPQ8Dx4uQDmoIlVPLWE27Od3fxoe0IUvuoPHE
6 changed files with 98 additions and 20 deletions

View file

@ -5,7 +5,10 @@
config,
...
}:
lib.mkIf osConfig.programs.hyprland.enable {
let
inherit (lib) mapAttrsToList mkIf hasAttr;
in
mkIf osConfig.programs.hyprland.enable {
home.sessionVariables.ELECTRON_OZONE_PLATFORM_HINT = "auto";
wayland.windowManager.hyprland = {
@ -14,10 +17,15 @@ lib.mkIf osConfig.programs.hyprland.enable {
settings = {
"$mod" = "SUPER";
monitor = [
"DP-2,1920x1080@144, 0x0, 1"
"HDMI-A-1,1920x1080@60, 1920x0, 1"
];
monitor = mapAttrsToList (
name: value:
let
inherit (value) resX resY scale;
posFinal = "${toString value.posX}x${toString value.posY}";
rrFinal = if hasAttr "rr" value then "@${toString value.rr}" else "";
in
"${name}, ${toString resX}x${toString resY}${rrFinal}, ${posFinal}, ${toString scale}"
) osConfig.modules.system.outputs;
exec-once = [
"${config.services.kdeconnect.package}/bin/kdeconnect-indicator"
@ -51,6 +59,7 @@ lib.mkIf osConfig.programs.hyprland.enable {
input = {
numlock_by_default = true;
kb_options = "compose:caps";
kb_layout = osConfig.console.keyMap;
};
decoration = {
@ -60,10 +69,12 @@ lib.mkIf osConfig.programs.hyprland.enable {
active_opacity = 1.0;
inactive_opacity = 1.0;
drop_shadow = true;
shadow_range = 4;
shadow_render_power = 3;
"col.shadow" = "rgba(1a1a1aee)";
shadow = {
enabled = true;
range = 4;
render_power = 3;
color = "rgba(1a1a1aee)";
};
# https://wiki.hyprland.org/Configuring/Variables/#blur
blur = {

View file

@ -6,6 +6,9 @@
osConfig,
...
}:
let
inherit (lib) mapAttrs;
in
lib.mkIf osConfig.programs.sway.enable {
services.swayidle.enable = true;
@ -199,14 +202,12 @@ lib.mkIf osConfig.programs.sway.enable {
};
#: }}}
#: Output {{{
output = {
eDP-1 = {
scale = "2";
pos = "0 0";
res = "3840x2400";
adaptive_sync = "on";
};
};
output = mapAttrs (name: value: {
scale = toString value.scale;
pos = "${toString value.posX} ${toString value.posY}";
res = "${toString value.resX}x${toString value.resY}";
adaptive_sync = "on";
}) osConfig.modules.system.outputs;
#: }}}
};
};

View file

@ -32,9 +32,23 @@
};
modules = {
system.networking = {
wifi.enable = true;
bluetooth.enable = true;
system = {
outputs = {
"DP-2" = {
resX = 1920;
resY = 1080;
};
"HDMI-A-1" = {
posX = 1920;
resX = 1920;
resY = 1080;
};
};
networking = {
wifi.enable = true;
bluetooth.enable = true;
};
};
services = {
@ -81,6 +95,7 @@
firefox.enable = true;
thunderbird.enable = true;
sway.enable = true;
hyprland.enable = true;
};
security.polkit.enable = true;

View file

@ -17,6 +17,13 @@
media.enableAll = true;
system = {
outputs = {
eDP-1 = {
resX = 3840;
resY = 2400;
scale = 2.0;
};
};
networking = {
bluetooth.enable = true;
wifi.enable = true;

View file

@ -2,5 +2,6 @@
imports = [
./networking
./roles
./outputs.nix
];
}

View file

@ -0,0 +1,43 @@
{ lib, ... }:
let
inherit (lib) mkOption;
inherit (lib.types)
attrsOf
submodule
int
float
str
;
in
{
options.modules.system.outputs = mkOption {
type = attrsOf (
submodule (
{ name, config, ... }:
{
options = {
name = mkOption {
type = str;
default = name;
};
scale = mkOption {
type = float;
default = 1.0;
};
posX = mkOption {
type = int;
default = 0;
};
posY = mkOption {
type = int;
default = 0;
};
resX = mkOption { type = int; };
resY = mkOption { type = int; };
};
}
)
);
default = { };
};
}