Display: Add rotate option.

This commit is contained in:
Dmitry Voronin 2024-11-18 02:24:48 +03:00
parent 524efdf533
commit f67f3580ec
Signed by: voronind
SSH key fingerprint: SHA256:3kBb4iV2ahufEBNq+vFbUe4QYfHt98DHQjN7QaptY9k
13 changed files with 87 additions and 30 deletions

42
config/Display.nix Normal file
View file

@ -0,0 +1,42 @@
{
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;
})
];
}

View file

@ -101,7 +101,6 @@ in {
(lib.mkIf cfg.server {
module = {
keyd.enable = true;
kernel = {
enable = true;
hardening = true;

View file

@ -1,6 +1,7 @@
{
util,
config,
lib,
util,
...
} @args: let
swayRc = util.catText [
@ -32,6 +33,6 @@ in {
include /etc/sway/config.d/*
'')
+ swayRc
+ config.module.sway.extraConfig
+ lib.concatStringsSep "\n" config.module.sway.extraConfig
;
}

View file

@ -16,10 +16,7 @@ in {
spacing = 4;
start_hidden = false;
output = [
"!AOC 24G2W1G4 ATNL61A129625" # Dasha monitor.
"!Huawei Technologies Co., Inc. ZQE-CBA 0xC080F622" # Desktop monitor.
"!UGD Artist15.6Pro 20200316" # XP-Pen Tablet.
"*"
config.module.display.primary
];
modules-left = [
"clock"

View file

@ -6,8 +6,9 @@
};
module = {
builder.client.enable = true;
amd.gpu.enable = true;
builder.client.enable = true;
display.primary = "DP-1";
package.extra = true;
print.enable = true;
purpose = {

View file

@ -14,6 +14,10 @@
gaming = true;
work = true;
};
display = {
primary = "HDMI-A-1";
rotate.HDMI-A-1 = 180;
};
amd = {
compute.enable = true;
gpu.enable = true;
@ -22,11 +26,11 @@
powersave = true;
};
};
sway.extraConfig = ''
output "ASUSTek COMPUTER INC ASUS VA24E R2LMTF127165" mode 1920x1080@74.986Hz transform 180 pos 780,0
output "Huawei Technologies Co., Inc. ZQE-CBA 0xC080F622" pos 0,1080
workspace 1 output "ASUSTek COMPUTER INC ASUS VA24E R2LMTF127165"
'';
sway.extraConfig = [
"output DP-3 pos 0,1080"
"output HDMI-A-1 mode 1920x1080@74.986Hz pos 780,0"
"workspace 1 output HDMI-A-1"
];
hwmon = {
file = "temp1_input";
path = "/sys/devices/pci0000:00/0000:00:18.3/hwmon";

View file

@ -7,6 +7,7 @@
module = {
builder.server.enable = true;
display.primary = "HDMI-A-1";
purpose = {
desktop = true;
router = true;

View file

@ -8,6 +8,7 @@
module = {
builder.client.enable = true;
display.primary = "eDP-1";
print.enable = true;
purpose = {
creativity = true;

View file

@ -1,6 +0,0 @@
{ ... }: {
boot.kernelParams = [
"fbcon=rotate:1"
"video=DSI-1:rotate=90"
];
}

View file

@ -15,10 +15,16 @@
laptop = true;
work = true;
};
sway.extraConfig = ''
output DSI-1 transform 90
input type:touch map_to_output DSI-1
'';
display = {
primary = "DSI-1";
rotate = {
tty = 90;
DSI-1 = 90;
};
};
sway.extraConfig = [
"input type:touch map_to_output DSI-1"
];
hwmon = {
file = "temp1_input";
path = "/sys/devices/platform/coretemp.0/hwmon";

View file

@ -11,6 +11,7 @@
module = {
builder.client.enable = true;
display.primary = "DSI-1";
package.extra = true;
powerlimit.thinkpad.enable = true;
print.enable = true;

View file

@ -3,8 +3,18 @@
lib,
...
}: {
options.module.display.dpiAware = lib.mkOption {
options.module.display = {
dpiAware = lib.mkOption {
default = false;
type = lib.types.bool;
};
primary = lib.mkOption {
default = "*";
type = lib.types.str;
};
rotate = lib.mkOption {
default = { };
type = with lib.types; attrsOf (enum [ 0 90 180 270 ]);
};
};
}

View file

@ -5,8 +5,8 @@
options.module.sway = {
enable = lib.mkEnableOption "the Sway WM.";
extraConfig = lib.mkOption {
default = "";
type = lib.types.str;
default = [ ];
type = with lib.types; listOf str;
};
};
}