nix/config/Display.nix

52 lines
1.4 KiB
Nix
Raw Normal View History

{ lib, config, ... }:
let
cfg = config.module.display;
in
2024-11-18 02:24:48 +03:00
{
# 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
# ISSUE: https://github.com/swaywm/sway/issues/8478
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";
2024-11-18 02:24:48 +03:00
value =
if rotate == 90 then
1
else if rotate == 180 then
2
else if rotate == 270 then
3
else
0;
2024-11-18 02:24:48 +03:00
command =
if name == "tty" then
"fbcon=rotate:${toString value}"
else
"video=${name}:rotate=${toString rotate}";
in
# "video=${name}:panel_orientation=${hint}";
# "video=${name}:rotate=${toString rotate},panel_orientation=${hint}";
command
) cfg.rotate;
2024-11-18 02:24:48 +03:00
module.sway.extraConfig = lib.mapAttrsToList (
name: rotate: "output ${name} transform ${toString rotate}"
) cfg.rotate;
})
];
2024-11-18 02:24:48 +03:00
}