mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 06:39:14 +00:00
vanadium: refactor autorandr config
This commit is contained in:
parent
7d24683787
commit
abc5a20069
1 changed files with 33 additions and 32 deletions
|
|
@ -33,54 +33,56 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
profiles = let
|
profiles = let
|
||||||
built-in = "00ffffffffffff0009e5ca0b000000002f200104a51c137803de50a3544c99260f505400000001010101010101010101010101010101115cd01881e02d50302036001dbe1000001aa749d01881e02d50302036001dbe1000001a000000fe00424f452043510a202020202020000000fe004e4531333546424d2d4e34310a0073";
|
|
||||||
asus-monitor = "00ffffffffffff0006b35b27010101012c210103803c22782a29d5ad4f44a7240f5054bfef00714f81809500d1c0d1e8d1fc01010101565e00a0a0a029503020350055502100001a000000fd0030901edf3c000a202020202020000000fc005647323741514c33410a202020000000ff0052414c4d51533139373533370a0111020347f14a90030204014061603f1f230907078301000067030c002000384468d85dc401788003026d1a000002013090f00069096909e305ff01e6060701696900e2006ae20fc0eae70070a0a067500820980455502100001a6fc200a0a0a055503020350055502100001a5aa000a0a0a046503020350055502100001a0000bc";
|
|
||||||
|
|
||||||
allExternDevices =
|
|
||||||
map (portNumber: "DP-${toString portNumber}") (lib.range 1 8);
|
|
||||||
|
|
||||||
allDevices = ["eDP-1"] ++ allExternDevices;
|
|
||||||
|
|
||||||
# TODO: merge when upstream is merged
|
# TODO: merge when upstream is merged
|
||||||
# https://github.com/NixOS/nixpkgs/pull/436434
|
# https://github.com/NixOS/nixpkgs/pull/436434
|
||||||
#
|
#
|
||||||
# Generate an attribute set by mapping a function over a list of attribute names.
|
# Generate an attribute set by mapping a function over a list of attribute names.
|
||||||
# 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);
|
||||||
|
singleton = k: v: {${k} = v;};
|
||||||
|
|
||||||
|
fingerprints = {
|
||||||
|
built-in = singleton "eDP-1" "00ffffffffffff0009e5ca0b000000002f200104a51c137803de50a3544c99260f505400000001010101010101010101010101010101115cd01881e02d50302036001dbe1000001aa749d01881e02d50302036001dbe1000001a000000fe00424f452043510a202020202020000000fe004e4531333546424d2d4e34310a0073";
|
||||||
|
asus-monitor = device: singleton device "00ffffffffffff0006b35b27010101012c210103803c22782a29d5ad4f44a7240f5054bfef00714f81809500d1c0d1e8d1fc01010101565e00a0a0a029503020350055502100001a000000fd0030901edf3c000a202020202020000000fc005647323741514c33410a202020000000ff0052414c4d51533139373533370a0111020347f14a90030204014061603f1f230907078301000067030c002000384468d85dc401788003026d1a000002013090f00069096909e305ff01e6060701696900e2006ae20fc0eae70070a0a067500820980455502100001a6fc200a0a0a055503020350055502100001a5aa000a0a0a046503020350055502100001a0000bc";
|
||||||
|
};
|
||||||
|
|
||||||
|
devices = rec {
|
||||||
|
built-in = "eDP-1";
|
||||||
|
# Run `xrandr` to see the max number
|
||||||
|
extern = map (portNumber: "DP-${toString portNumber}") (lib.range 1 8);
|
||||||
|
all = [built-in] ++ extern;
|
||||||
|
};
|
||||||
|
|
||||||
switches = {
|
switches = {
|
||||||
setDPI = {dpi}: {
|
setDPI = {dpi}:
|
||||||
"10_xrdb-dpi" = "xrdb -merge ${pkgs.writeText "xrdb-dpi-config" ''
|
singleton "10_xrdb-dpi" "xrdb -merge ${pkgs.writeText "xrdb-dpi-config" ''
|
||||||
Xcursor.size: 64
|
Xcursor.size: 64
|
||||||
Xft.dpi: ${toString dpi}
|
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
|
||||||
setSoftwareBrightness = {
|
setSoftwareBrightness = {
|
||||||
device, # obtain with `xrandr`
|
device, # obtain with `xrandr`
|
||||||
brightness, # [0..1]
|
brightness, # [0..1]
|
||||||
}: {
|
}:
|
||||||
"10_xrandr_brightness" = ''
|
singleton "10_xrandr_brightness" ''
|
||||||
xrandr --output ${device} --brightness ${toString brightness}
|
xrandr --output ${device} --brightness ${toString brightness}
|
||||||
'';
|
'';
|
||||||
};
|
|
||||||
|
|
||||||
# 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
|
||||||
setDDCBrightness = {
|
setDDCBrightness = {
|
||||||
modelName, # obtain with `ddcutil detect`
|
modelName, # obtain with `ddcutil detect`
|
||||||
brightness, # [0..1]
|
brightness, # [0..1]
|
||||||
}: {
|
}:
|
||||||
"10_ddc_brightness" = ''
|
singleton "10_ddc_brightness" ''
|
||||||
ddcutil --model ${modelName} setvcp 10 ${toString (brightness * 100)}
|
ddcutil --model ${modelName} setvcp 10 ${toString (brightness * 100)}
|
||||||
'';
|
'';
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# Note: the "position" field corresponds to the "pos" field outputted by autorandr
|
# Note: the "position" field corresponds to the "pos" field outputted by autorandr
|
||||||
# To get the current config, run `xrandr --auto` and then `autorandr --config`
|
# To get the current config, run `xrandr --auto` and then `autorandr --config`
|
||||||
configs = {
|
configs = {
|
||||||
allOff = lib.genAttrs allDevices (_: {enable = false;});
|
allOff = lib.genAttrs devices.all (_: {enable = false;});
|
||||||
enableBuiltin = {
|
enableBuiltin = {
|
||||||
eDP-1 = {
|
eDP-1 = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
@ -103,30 +105,29 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
frameworkBuiltin = {
|
frameworkBuiltin = {
|
||||||
fingerprint.eDP-1 = built-in;
|
fingerprint = fingerprints.built-in;
|
||||||
config = with configs; allOff // enableBuiltin;
|
config = configs.allOff // configs.enableBuiltin;
|
||||||
hooks.postswitch = with switches; setDPI {dpi = 150;};
|
hooks.postswitch = switches.setDPI {dpi = 150;};
|
||||||
};
|
};
|
||||||
|
|
||||||
mkAsusProfile = name: {
|
mkAsusProfile = name: {
|
||||||
fingerprint = {
|
fingerprint = fingerprints.built-in // fingerprints.asus-monitor name;
|
||||||
${name} = asus-monitor;
|
config = configs.allOff // configs.enableDevice name;
|
||||||
eDP-1 = built-in;
|
hooks.postswitch =
|
||||||
};
|
switches.setDPI {dpi = 110;}
|
||||||
config = with configs; allOff // enableDevice name;
|
// switches.setDDCBrightness {
|
||||||
hooks.postswitch = with switches;
|
|
||||||
setDPI {dpi = 110;}
|
|
||||||
// setDDCBrightness {
|
|
||||||
modelName = "VG27AQL3A";
|
modelName = "VG27AQL3A";
|
||||||
brightness = 0;
|
brightness = 0;
|
||||||
}
|
}
|
||||||
// setSoftwareBrightness {
|
// switches.setSoftwareBrightness {
|
||||||
device = name;
|
device = name;
|
||||||
brightness = 0.7;
|
brightness = 0.7;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{default = frameworkBuiltin;}
|
lib.mkMerge [
|
||||||
// genAttrs' allExternDevices (name: lib.nameValuePair "asus-${name}" (mkAsusProfile name));
|
{default = frameworkBuiltin;}
|
||||||
|
(genAttrs' devices.extern (name: lib.nameValuePair "asus-${name}" (mkAsusProfile name)))
|
||||||
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue