From d1f89a624a98718247dd7e9ea40954c865225227 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cyryl=20P=C5=82otnicki?= Date: Fri, 12 Nov 2021 22:36:04 +0000 Subject: [PATCH] update suspend scripts --- nixos/common-hardware.nix | 9 +++++++-- nixos/i3/autorandr.nix | 12 ++++++------ nixos/i3/xidlehook.nix | 5 ++++- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/nixos/common-hardware.nix b/nixos/common-hardware.nix index de1dc0f6..7de8f0bb 100644 --- a/nixos/common-hardware.nix +++ b/nixos/common-hardware.nix @@ -83,6 +83,11 @@ extraBackends = with pkgs; [ samsung-unified-linux-driver ]; }; - powerManagement.enable = (lib.mkForce true); - powerManagement.powertop.enable = true; + powerManagement = { + enable = (lib.mkForce true); + resumeCommands = '' + ${pkgs.autorandr}/bin/autorandr -c + ''; + powertop.enable = true; + }; } diff --git a/nixos/i3/autorandr.nix b/nixos/i3/autorandr.nix index 292acfe0..7284bf3b 100644 --- a/nixos/i3/autorandr.nix +++ b/nixos/i3/autorandr.nix @@ -8,14 +8,14 @@ "change-dpi" = '' case "$AUTORANDR_CURRENT_PROFILE" in foureighty-docked) - DPI=144 - ;; + DPI=144 + ;; foureighty) - DPI=144 - ;; + DPI=144 + ;; *) - echo "Unknown profle: $AUTORANDR_CURRENT_PROFILE" - exit 1 + echo "Unknown profle: $AUTORANDR_CURRENT_PROFILE" + exit 1 esac echo "changing DPI to $DPI" ${pkgs.xorg.xrandr}/bin/xrandr --dpi $DPI diff --git a/nixos/i3/xidlehook.nix b/nixos/i3/xidlehook.nix index c6214f86..1d3d97e8 100644 --- a/nixos/i3/xidlehook.nix +++ b/nixos/i3/xidlehook.nix @@ -15,7 +15,10 @@ } { delay = 600; - command = "xrandr --output \"$PRIMARY_DISPLAY\" --brightness 1; systemctl suspend"; + command = "${pkgs.writeShellScript "my-script" '' + xrandr --output "$PRIMARY_DISPLAY" --brightness 1 + systemctl suspend + ''}"; } ];