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 { (lib.mkIf cfg.server {
module = { module = {
keyd.enable = true;
kernel = { kernel = {
enable = true; enable = true;
hardening = true; hardening = true;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -8,6 +8,7 @@
module = { module = {
builder.client.enable = true; builder.client.enable = true;
display.primary = "eDP-1";
print.enable = true; print.enable = true;
purpose = { purpose = {
creativity = true; 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; laptop = true;
work = true; work = true;
}; };
sway.extraConfig = '' display = {
output DSI-1 transform 90 primary = "DSI-1";
input type:touch map_to_output DSI-1 rotate = {
''; tty = 90;
DSI-1 = 90;
};
};
sway.extraConfig = [
"input type:touch map_to_output DSI-1"
];
hwmon = { hwmon = {
file = "temp1_input"; file = "temp1_input";
path = "/sys/devices/platform/coretemp.0/hwmon"; path = "/sys/devices/platform/coretemp.0/hwmon";

View file

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

View file

@ -3,8 +3,18 @@
lib, lib,
... ...
}: { }: {
options.module.display.dpiAware = lib.mkOption { options.module.display = {
default = false; dpiAware = lib.mkOption {
type = lib.types.bool; 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 = { options.module.sway = {
enable = lib.mkEnableOption "the Sway WM."; enable = lib.mkEnableOption "the Sway WM.";
extraConfig = lib.mkOption { extraConfig = lib.mkOption {
default = ""; default = [ ];
type = lib.types.str; type = with lib.types; listOf str;
}; };
}; };
} }