bin: add nvidia-offload and cputil scripts
Anirudh Oppiliappan x@icyphox.sh
Fri, 29 Apr 2022 15:01:14 +0530
3 files changed,
51 insertions(+),
0 deletions(-)
A
nix/bin/cputil.nix
@@ -0,0 +1,33 @@
+{ pkgs, ... }: + +let + name = "cputil"; + cpufreqctl = "${pkgs.auto-cpufreq}/bin/cpufreqctl.auto-cpufreq"; + asusctl = "${pkgs.asusctl}/bin/asusctl"; +in +pkgs.writeShellScriptBin name + '' + mode="$1" + case "$mode" in + "perf") + doas ${cpufreqctl} --governor --set=performance + ${asusctl} profile -P performance + printf "turning on cores... " + for i in {8..15}; do + printf "$i " + doas ${cpufreqctl} --on --core=$i + done + printf "\n" + ;; + "save") + doas ${cpufreqctl} --governor --set=powersave + ${asusctl} profile -P quiet + printf "turning off cores... " + for i in {8..15}; do + printf "$i " + doas ${cpufreqctl} --off --core=$i + done + printf "\n" + esac + '' +
M
nix/bin/default.nix
→
nix/bin/default.nix
@@ -51,6 +51,12 @@ battery = import ./battery.nix pkgs;
# invert screen invert = import ./invert.nix pkgs; + + # nvidia offload + nvidia-offload = import ./nvidia-offload.nix pkgs; + + # power profiles script + cputil = import ./cputil.nix pkgs; in [ git-new-push-remote@@ -62,4 +68,6 @@ battery
bar xurls invert + nvidia-offload + cputil ]
A
nix/bin/nvidia-offload.nix
@@ -0,0 +1,10 @@
+{ pkgs, ... }: + +pkgs.writeShellScriptBin "nvidia-offload" + '' + export __NV_PRIME_RENDER_OFFLOAD=1 + export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0 + export __GLX_VENDOR_LIBRARY_NAME=nvidia + export __VK_LAYER_NV_optimus=NVIDIA_only + exec -a "$0" "$@" + ''