about summary refs log tree commit diff
path: root/common-workstation.nix
diff options
context:
space:
mode:
authoraszlig <aszlig@redmoonstudios.org>2014-10-16 19:50:41 +0200
committeraszlig <aszlig@redmoonstudios.org>2014-10-16 19:50:41 +0200
commita991b1d429d0debc4c49f0f75bebdd6c83072848 (patch)
treed0357548bd326794c78160d9b66d613d2f3500f1 /common-workstation.nix
parent399055151de7a6318ce23e95e01c0763e30c62a7 (diff)
common-workstations: Add a XrandR reset command.
Simply a command callod "xreset", which resets the monitor configuration
back to what was configured for the X server.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Diffstat (limited to 'common-workstation.nix')
-rw-r--r--common-workstation.nix15
1 files changed, 14 insertions, 1 deletions
diff --git a/common-workstation.nix b/common-workstation.nix
index 5d5f9f73..cb43609d 100644
--- a/common-workstation.nix
+++ b/common-workstation.nix
@@ -1,4 +1,4 @@
-{ pkgs, ... }:
+{ pkgs, config, lib, ... }:
 
 {
   imports = [
@@ -11,6 +11,19 @@
   boot.kernelParams = [ "zswap.enabled=1" ];
   boot.cleanTmpDir = true;
 
+  environment.systemPackages = with lib; let
+    mkRandrConf = acc: name: acc ++ singleton {
+      inherit name;
+      value = "--output '${name}' --preferred"
+            + optionalString (acc != []) " --right-of '${(head acc).name}'";
+    };
+    randrHeads = config.services.xserver.xrandrHeads;
+    randrConf = map (getAttr "value") (foldl mkRandrConf [] randrHeads);
+  in singleton (pkgs.writeScriptBin "xreset" ''
+    #!${pkgs.stdenv.shell}
+    ${pkgs.xorg.xrandr}/bin/xrandr ${concatStringsSep " " randrConf}
+  '');
+
   hardware = {
     pulseaudio.enable = true;
     pulseaudio.package = pkgs.pulseaudio.override {