From bab392f4e186eeebef31e85867f4124eb2e102a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9ana=20=E6=B1=9F?= Date: Sat, 6 Sep 2025 09:14:09 +0800 Subject: [PATCH] vanadium: refactor autorandr config --- nix/configurations/vanadium/nixos/display.nix | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/nix/configurations/vanadium/nixos/display.nix b/nix/configurations/vanadium/nixos/display.nix index 185e5884..ce68a6e9 100644 --- a/nix/configurations/vanadium/nixos/display.nix +++ b/nix/configurations/vanadium/nixos/display.nix @@ -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 };