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