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,7 +48,8 @@
# It allows setting the name of the attribute.
genAttrs' = xs: func: builtins.listToAttrs (map func xs);
mkDpiSwitch = {dpi}: {
switches = {
setDPI = {dpi}: {
"10_xrdb-dpi" = "xrdb -merge ${pkgs.writeText "xrdb-dpi-config" ''
Xcursor.size: 64
Xft.dpi: ${toString dpi}
@ -56,7 +57,7 @@
};
# Is scoped to an output device, no need to be called on built-in display
mkBrightnessSwitch = {
setSoftwareBrightness = {
device,
brightness,
}: {
@ -64,6 +65,7 @@
xrandr --output ${device} --brightness ${toString brightness}
'';
};
};
# Note: the "position" field corresponds to the "pos" field outputted by autorandr
# To get the current config, run `xrandr --auto` and then `autorandr --config`
@ -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
};