vanadium: refactor autorandr config

This commit is contained in:
Primrose 2025-09-06 09:14:09 +08:00
parent 6dac446be8
commit bab392f4e1
Signed by: primrose
GPG key ID: 4E887A4CA9714ADA

View file

@ -48,21 +48,23 @@
# It allows setting the name of the attribute. # It allows setting the name of the attribute.
genAttrs' = xs: func: builtins.listToAttrs (map func xs); genAttrs' = xs: func: builtins.listToAttrs (map func xs);
mkDpiSwitch = {dpi}: { switches = {
"10_xrdb-dpi" = "xrdb -merge ${pkgs.writeText "xrdb-dpi-config" '' setDPI = {dpi}: {
Xcursor.size: 64 "10_xrdb-dpi" = "xrdb -merge ${pkgs.writeText "xrdb-dpi-config" ''
Xft.dpi: ${toString dpi} Xcursor.size: 64
''}"; Xft.dpi: ${toString dpi}
}; ''}";
};
# Is scoped to an output device, no need to be called on built-in display # Is scoped to an output device, no need to be called on built-in display
mkBrightnessSwitch = { setSoftwareBrightness = {
device, device,
brightness, brightness,
}: { }: {
"10_xrandr_brightness" = '' "10_xrandr_brightness" = ''
xrandr --output ${device} --brightness ${toString brightness} xrandr --output ${device} --brightness ${toString brightness}
''; '';
};
}; };
# Note: the "position" field corresponds to the "pos" field outputted by autorandr # Note: the "position" field corresponds to the "pos" field outputted by autorandr
@ -93,7 +95,7 @@
frameworkBuiltin = { frameworkBuiltin = {
fingerprint.eDP-1 = built-in; fingerprint.eDP-1 = built-in;
config = with configs; allOff // enableBuiltin; config = with configs; allOff // enableBuiltin;
hooks.postswitch = mkDpiSwitch {dpi = 150;}; hooks.postswitch = with switches; setDPI {dpi = 150;};
}; };
mkAsusProfile = name: { mkAsusProfile = name: {
@ -102,9 +104,9 @@
eDP-1 = built-in; eDP-1 = built-in;
}; };
config = with configs; allOff // enableDevice name; config = with configs; allOff // enableDevice name;
hooks.postswitch = hooks.postswitch = with switches;
mkDpiSwitch {dpi = 110;} setDPI {dpi = 110;}
// mkBrightnessSwitch { // setSoftwareBrightness {
device = name; device = name;
brightness = 0.7; # just a random sensible choice brightness = 0.7; # just a random sensible choice
}; };