shell: update fixdisplay command

- add new `position` and `primary` options for fixdisplay
- make command completely lowercase
- initialize global zshrc
This commit is contained in:
Oystein Kristoffer Tveit 2022-11-20 17:12:27 +01:00
parent b02fb0734b
commit 8de5dd5f23
Signed by: oysteikt
GPG Key ID: 9F2F7D8250F35146
4 changed files with 41 additions and 25 deletions

View File

@ -152,17 +152,17 @@ in {
}; };
}; };
shellAliases.fixDisplay = let shellAliases.fixdisplay = let
inherit (config.machineVars) screens headless fixDisplayCommand; inherit (config.machineVars) screens headless fixDisplayCommand;
screenToArgs = screen: with screen; screenToArgs = name: screen: with screen;
"--output ${name} --mode ${resolution}" "--output ${name} --mode ${resolution} --rate ${toString frequency} --pos ${position}"
+ (lib.optionalString (frequency != null) " --rate ${frequency}"); + (lib.optionalString primary " --primary");
screenArgs = lib.concatStringsSep " " (lib.mapAttrsToList screenToArgs screens); screenArgs = lib.concatStringsSep " " (lib.mapAttrsToList screenToArgs screens);
in lib.mkIf (!headless) in lib.mkIf (!headless)
(if screenArgs == null (if screenArgs != null
then "xrandr ${screenArgs}" then "xrandr ${screenArgs}"
else (lib.mkIf (fixDisplayCommand != null) fixDisplayCommand)); else (lib.mkIf (fixDisplayCommand != null) fixDisplayCommand));
}; };
@ -305,6 +305,7 @@ in {
light.enable = !config.machineVars.headless; light.enable = !config.machineVars.headless;
npm.enable = true; npm.enable = true;
tmux.enable = true; tmux.enable = true;
zsh.enable = true;
gnupg.agent = { gnupg.agent = {
enable = true; enable = true;

View File

@ -20,11 +20,7 @@ in {
headless = false; headless = false;
laptop = true; laptop = true;
screens = { screens."eDP-1".primary = true;
"eDP-1" = {
resolution = "1920x1080";
};
};
}; };
systemd.targets = { systemd.targets = {

View File

@ -25,12 +25,15 @@
default = main; default = main;
}; };
fixDisplayCommand = "xrandr --output DP-4 --mode 1920x1080 --pos 0x0 -r 144 --output HDMI-0 --primary --mode 1920x1080 --pos 1920x0 -r 60"; screens = {
DP-4 = {
# screens = { primary = true;
# "DP-1" = {}; frequency = 144;
# "HDMI-1" = {}; };
# }; HDMI-0 = {
position = "1920x0";
};
};
}; };
systemd.targets = { systemd.targets = {

View File

@ -9,12 +9,6 @@ in {
screens = mkOption { screens = mkOption {
type = types.attrsOf (types.submodule ( { name, ...}: { type = types.attrsOf (types.submodule ( { name, ...}: {
options = { options = {
resolution = mkOption {
type = types.str;
example = "1920x1080";
description = "The resolution of the screen";
};
name = mkOption { name = mkOption {
type = types.str; type = types.str;
default = name; default = name;
@ -22,11 +16,28 @@ in {
description = "The name of the screen"; description = "The name of the screen";
}; };
freq = mkOption { primary = mkEnableOption "Whether this screen should be the primary one. There can only be one primary screen";
type = types.nullOr types.str;
example = "60.00"; resolution = mkOption {
type = types.str;
example = "3840x2160";
default = "1920x1080";
description = "The resolution of the screen";
};
frequency = mkOption {
type = types.ints.positive;
example = 144;
default = 60;
description = "The update frequency of the screen, defined in Hz"; description = "The update frequency of the screen, defined in Hz";
}; };
position = mkOption {
type = types.str;
example = "1920x0";
default = "0x0";
description = "The position of the screen, compared to the other screens";
};
}; };
})); }));
default = { }; default = { };
@ -102,6 +113,11 @@ t tools preinstalled.";
assertion = cfg.battery != null -> cfg.laptop; assertion = cfg.battery != null -> cfg.laptop;
message = "A battery shouldn't exist on a non laptop machine"; message = "A battery shouldn't exist on a non laptop machine";
} }
# FIXME:
# {
# assertion = map () (cfg.screens)
# message = "There can only be one primary screen.";
# }
]; ];
warnings = lib.optionals (0 < (lib.length (builtins.attrNames cfg.screens)) && (cfg.fixDisplayCommand != null)) [ warnings = lib.optionals (0 < (lib.length (builtins.attrNames cfg.screens)) && (cfg.fixDisplayCommand != null)) [