Compare commits

...

4 Commits

4 changed files with 20 additions and 17 deletions

View File

@ -50,17 +50,20 @@
systemd.user.services.screenlayout = { systemd.user.services.screenlayout = {
script = '' script = lib.getExe
${pkgs.xorg.xrandr}/bin/xrandr \ (pkgs.writeXrandrScriptBin "default-monitors" {
--output DP-0 --primary --mode 1920x1080 --pos 1920x0 --rotate normal \ DP-0 = {
--output HDMI-0 --mode 1920x1080 --pos 0x0 --rotate normal \ primary = true;
--output DP-1 --off \ mode = "1920x1080";
--output DP-2 --off \ pos = "1920x0";
--output DP-3 --off \ rotate = "normal";
--output DP-4 --off \ };
--output DP-5 --off \ HDMI-0 = {
--output HDMI-1 --off mode = "1920x1080";
''; pos = "0x0";
rotate = "normal";
};
});
wantedBy = [ "graphical-session.target" ]; wantedBy = [ "graphical-session.target" ];
partOf = [ "graphical-session.target" ]; partOf = [ "graphical-session.target" ];
}; };

View File

@ -3,6 +3,6 @@ let
callDefaultPackage = path: prev.callPackage path { }; callDefaultPackage = path: prev.callPackage path { };
in in
{ {
wrapWine = callDefaultPackage ./wrapWine.nix; wrapWine = callDefaultPackage ./wrapWine;
writeXrandrScriptBin = callDefaultPackage ./writeXrandrScriptBin.nix; writeXrandrScriptBin = callDefaultPackage ./writeXrandrScriptBin;
} }

View File

@ -1,7 +1,7 @@
{ lib, writeShellScriptBin }: { lib, writeShellScriptBin, xrandr }:
let let
inherit (builtins) getAttr hasAttr isAttrs concatStringsSep; inherit (builtins) getAttr hasAttr isAttrs concatStringsSep;
inherit (lib) assertMsg lists escapeShellArgs; inherit (lib) assertMsg lists escapeShellArgs getExe;
inherit (lib.attrsets) mapAttrsToList; inherit (lib.attrsets) mapAttrsToList;
inherit (lib.cli) toGNUCommandLine; inherit (lib.cli) toGNUCommandLine;
in in
@ -14,7 +14,7 @@ let
getArgList = output: config: getArgList = output: config:
(escapeShellArgs (lists.flatten [ (escapeShellArgs (lists.flatten [
(toGNUCommandLine { } { "--output" = output; }) (toGNUCommandLine { } { inherit output; })
(lists.optional (isPrimary config) "--primary") (lists.optional (isPrimary config) "--primary")
(toGNUCommandLine { } config) (toGNUCommandLine { } config)
])); ]));
@ -22,6 +22,6 @@ let
args = mapAttrsToList getArgList config; args = mapAttrsToList getArgList config;
in in
writeShellScriptBin name '' writeShellScriptBin name ''
xrandr \ ${getExe xrandr} \
${concatStringsSep " \\\n " args} ${concatStringsSep " \\\n " args}
'' ''