Files
nix-config/modules/nixos/desktop/game/gamemode.nix
2024-01-22 22:42:51 +08:00

49 lines
1.3 KiB
Nix

# https://github.com/fufexan/dotfiles/blob/483680e121b73db8ed24173ac9adbcc718cbbc6e/system/programs/gamemode.nix
{
config,
pkgs,
nix-gaming,
lib,
...
}: let
programs = lib.makeBinPath [
config.programs.hyprland.package
pkgs.coreutils
pkgs.power-profiles-daemon
];
startscript = pkgs.writeShellScript "gamemode-start" ''
export PATH=$PATH:${programs}
export HYPRLAND_INSTANCE_SIGNATURE=$(ls -1 /tmp/hypr | tail -1)
hyprctl --batch 'keyword decoration:blur 0 ; keyword animations:enabled 0 ; keyword misc:vfr 0'
powerprofilesctl set performance
'';
endscript = pkgs.writeShellScript "gamemode-end" ''
export PATH=$PATH:${programs}
export HYPRLAND_INSTANCE_SIGNATURE=$(ls -1 /tmp/hypr | tail -1)
hyprctl --batch 'keyword decoration:blur 1 ; keyword animations:enabled 1 ; keyword misc:vfr 1'
powerprofilesctl set power-saver
'';
in {
programs.gamemode = {
enable = true;
settings = {
general = {
softrealtime = "auto";
renice = 15;
};
custom = {
start = startscript.outPath;
end = endscript.outPath;
};
};
};
# see https://github.com/fufexan/nix-gaming/#pipewire-low-latency
services.pipewire.lowLatency.enable = true;
imports = [
nix-gaming.nixosModules.pipewireLowLatency
];
}