feat(lib): add hypr.mkMonitor helper function
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2025-02-05 14:55:34 -05:00
parent e703509ff1
commit 788b9e92c3
2 changed files with 85 additions and 29 deletions

View file

@ -1,6 +1,7 @@
{ {
concatStringsSep, concatStringsSep,
elemAt, elemAt,
optional,
optionals, optionals,
... ...
}: rec { }: rec {
@ -34,7 +35,7 @@
(toString duration) (toString duration)
bezier bezier
] ]
++ optionals (style != null) [style] ++ optional (style != null) style
) )
); );
@ -52,6 +53,56 @@
}: }:
concatStringsSep "," ( concatStringsSep "," (
[modifier key dispatcher] [modifier key dispatcher]
++ optionals (command != null) [command] ++ optional (command != null) command
);
mkMonitor = {
description ? null,
name ? null,
resolution ? null,
refreshRate ? null,
position ? "auto",
scale ? "1",
transform ? null,
mirror ? null,
bitdepth ? null,
vrr ? null,
}: let
transformMap = {
"normal" = 0;
"90" = 1;
"180" = 2;
"270" = 3;
"normalf" = 4;
"90f" = 5;
"180f" = 6;
"270f" = 7;
};
in
concatStringsSep "," (
[
(
if name != null && description != null
then throw "description or name required"
else if name != null
then name
else "desc:${description}"
)
(
if resolution == null && refreshRate != null
then throw "resolution needed if refreshRate is specified"
else if resolution != null && refreshRate != null
then "${resolution}@${toString refreshRate}"
else if resolution != null && refreshRate == null
then resolution
else "preferred"
)
position
scale
]
++ optional (transform != null) "transform, ${toString transformMap.${transform}}"
++ optional (mirror != null) "mirror, ${mirror}"
++ optional (bitdepth != null) "bitdepth, ${toString bitdepth}"
++ optional (vrr != null) "vrr, ${toString vrr}"
); );
} }

View file

@ -5,7 +5,7 @@ self: {
... ...
}: let }: let
inherit (self.inputs) hyprland; inherit (self.inputs) hyprland;
inherit (self.lib.hypr) mkBind; inherit (self.lib.hypr) mkBind mkMonitor;
inherit (lib) attrValues concatStringsSep mkIf optionals; inherit (lib) attrValues concatStringsSep mkIf optionals;
@ -114,32 +114,37 @@ in {
]); ]);
xwayland.force_zero_scaling = true; xwayland.force_zero_scaling = true;
monitor = [ monitor = map mkMonitor [
(concatStringsSep "," [ {
"desc:Acer Technologies Acer K212HQL T3EAA0014201" description = "Lenovo Group Limited 0x41A0";
"1920x1080@60" resolution = "1920x1200";
"840x450, 1, transform, 3" refreshRate = 60;
]) position = "0x2920";
(concatStringsSep "," [ }
"desc:Lenovo Group Limited 0x41A0" {
"1920x1200@60" description = "Samsung Electric Company C27JG5x HTOM100586";
"0x2920, 1" resolution = "2560x1440";
]) refreshRate = 120;
(concatStringsSep "," [ position = "1920x12";
"desc:Samsung Electric Company C27JG5x HTOM100586" }
"2560x1440@120" {
"1920x120, 1" description = "GIGA-BYTE TECHNOLOGY CO. LTD. G27QC 0x00000B1D";
]) resolution = "2560x1440";
(concatStringsSep "," [ refreshRate = 120;
"desc:GIGA-BYTE TECHNOLOGY CO. LTD. G27QC 0x00000B1D" position = "1920x1560";
"2560x1440@120" }
"1920x1560, 1" {
]) description = "Acer Technologies Acer K212HQL T3EAA0014201";
(concatStringsSep "," [ resolution = "1920x1080";
"desc:Sharp Corporation LC-40LB480U 0x00000001" refreshRate = 60;
"1680x1050, auto, 1" position = "840x450";
"mirror, ${cfg.mainMonitor}" transform = "270";
]) }
{
description = "Sharp Corporation LC-40LB480U 0x00000001";
resolution = "1680x1050";
mirror = cfg.mainMonitor;
}
]; ];
"$mainMod" = "SUPER"; "$mainMod" = "SUPER";