nix/config/Display.nix

43 lines
1.1 KiB
Nix
Raw Normal View History

2024-11-18 02:24:48 +03:00
{
lib,
config,
...
}: let
cfg = config.module.display;
in {
# REF: https://www.kernel.org/doc/Documentation/fb/fbcon.txt
# REF: https://patchwork.kernel.org/project/dri-devel/patch/20191110154101.26486-10-hdegoede@redhat.com/#22993841
config = lib.mkMerge [
# NOTE: `tty` name is special.
(lib.mkIf (cfg.rotate != null) {
boot.kernelParams = lib.mapAttrsToList (name: rotate:
let
hint =
if rotate == 90 then "left_side_up"
else if rotate == 180 then "upside_down"
else if rotate == 270 then "right_side_up"
else "normal";
value =
if rotate == 90 then 1
else if rotate == 180 then 2
else if rotate == 270 then 3
else 0;
command = if name == "tty" then
"fbcon=rotate:${toString value}"
else
"video=${name}:rotate=${toString rotate}";
# "video=${name}:panel_orientation=${hint}";
# "video=${name}:rotate=${toString rotate},panel_orientation=${hint}";
in command
) cfg.rotate;
module.sway.extraConfig = lib.mapAttrsToList (name: rotate:
"output ${name} transform ${toString rotate}"
) cfg.rotate;
})
];
}