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