vanadium: minor refactor display config

This commit is contained in:
Primrose 2025-09-02 18:27:58 +08:00
parent a6be9276c0
commit e3c26ec831
Signed by: primrose
GPG key ID: 4E887A4CA9714ADA

View file

@ -41,13 +41,11 @@
allDevices = ["eDP-1"] ++ allExternDevices;
/**
TODO: merge when upstream is merged
https://github.com/NixOS/nixpkgs/pull/436434
Generate an attribute set by mapping a function over a list of attribute names.
It allows setting the name of the attribute.
*/
# TODO: merge when upstream is merged
# https://github.com/NixOS/nixpkgs/pull/436434
#
# Generate an attribute set by mapping a function over a list of attribute names.
# It allows setting the name of the attribute.
genAttrs' = xs: func: builtins.listToAttrs (map func xs);
mkDpiSwitch = {dpi}: {
@ -57,6 +55,7 @@
''}";
};
# Is scoped to an output device, no need to be called on built-in display
mkBrightnessSwitch = {
device,
brightness,
@ -69,10 +68,7 @@
# 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' allDevices (name: {
inherit name;
value = {enable = false;};
});
allOff = lib.genAttrs allDevices (_: {enable = false;});
enableBuiltin = {
eDP-1 = {
enable = true;
@ -96,8 +92,7 @@
frameworkBuiltin = {
fingerprint.eDP-1 = built-in;
config = with configs;
allOff // enableBuiltin;
config = with configs; allOff // enableBuiltin;
hooks.postswitch = mkDpiSwitch {dpi = 150;};
};
@ -106,8 +101,7 @@
${name} = asus-monitor;
eDP-1 = built-in;
};
config = with configs;
allOff // enableDevice name;
config = with configs; allOff // enableDevice name;
hooks.postswitch =
mkDpiSwitch {dpi = 110;}
// mkBrightnessSwitch {
@ -117,9 +111,6 @@
};
in
{default = frameworkBuiltin;}
// genAttrs' allExternDevices (name: {
name = "asus-${name}";
value = mkAsusProfile name;
});
// genAttrs' allExternDevices (name: lib.nameValuePair "asus-${name}" (mkAsusProfile name));
};
}