vanadium: rework autorandr config, take 2

This commit is contained in:
Primrose 2025-08-24 11:09:39 +08:00
parent 5cc3105824
commit ceff246f25
Signed by: primrose
GPG key ID: 4E887A4CA9714ADA

View file

@ -39,6 +39,8 @@
allExternDevices =
map (portNumber: "DP-${toString portNumber}") (lib.range 1 12);
allDevices = ["eDP-1"] ++ allExternDevices;
/**
Generate an attribute set by mapping a function over a list of attribute names.
It allows setting the name of the attribute.
@ -55,19 +57,18 @@
# Note: the "position" field corresponds to the "pos" field outputted by autorandr
# To get the current config, run `xrandr --auto` and then `autorandr --config`
configs = {
allOff = genAttrs' allExternDevices (name: {
allOff = genAttrs' allDevices (name: {
inherit name;
value = {enable = false;};
});
enableBuiltin = primary: {
eDP-1 =
{
enableBuiltin = {
eDP-1 = {
enable = true;
crtc = 0;
mode = "2256x1504";
rate = "60.00";
}
// lib.optionalAttrs primary {primary = true;};
primary = true;
};
};
enableDevice = name: {
${name} = {
@ -84,32 +85,24 @@
frameworkBuiltin = {
fingerprint.eDP-1 = built-in;
config = with configs;
allOff // enableBuiltin true;
allOff // enableBuiltin;
hooks.postswitch = mkExtSwitch {dpi = 150;};
};
mkAsusProfile = name: withBuiltin: {
mkAsusProfile = name: {
fingerprint = {
${name} = asus-monitor;
eDP-1 = built-in;
};
config = with configs;
allOff
// enableDevice name
// lib.optionalAttrs withBuiltin (enableBuiltin false);
allOff // enableDevice name;
hooks.postswitch = mkExtSwitch {dpi = 120;};
};
in
genAttrs' allExternDevices (name: {
name = "asus-${name}-builtin";
value = mkAsusProfile name true;
})
{default = frameworkBuiltin;}
// genAttrs' allExternDevices (name: {
name = "asus-${name}-no-builtin";
value = mkAsusProfile name false;
})
// {
laptop = frameworkBuiltin;
};
name = "asus-${name}";
value = mkAsusProfile name;
});
};
}