Gamemode

From NixOS Wiki
Revision as of 16:38, 18 May 2021 by imported>MetaDark

GameMode is a daemon/lib combo for Linux that allows games to request a set of optimisations be temporarily applied to the host OS and/or a game process.

Installation

GameMode depends on root-level capabilities that aren't available in a user-level Nix package installation. The easiest way to set this up is to use the NixOS module:

programs.gamemode.enable = true;

It's also possible to use GameMode without the NixOS module, but process renicing will not work:

environment.systemPackages = with pkgs; [
  gamemode
];
Note: CPU & GPU optimisations require root-level access. GameMode defines Polkit actions under share/polkit-1/actions to allow any user to perform the optimisations, but Polkit will only load these actions when installed in the system profile. If you install GameMode into a user profile, the optimisations will fail to apply.

Known Errors

Renice & ioprio optimisations sometimes fail. This is caused by GameMode trying to apply optimisations on processes that exit before the optimisations can be applied. See FeralInteractive/gamemode#167 (comment).

ERROR: Could not inspect tasks for client [329118]! Skipping ioprio optimisation.
ERROR: Refused to renice client [31477,31477]: prio was (-10) but we expected (0)

If you don't have an Intel CPU, you will get errors about failing to read the energy levels. This isn't a real problem. It just means that optimizations for integrated graphics cards won't be enabled:

ERROR: Failed to open file for read /sys/class/powercap/intel-rapl/intel-rapl:0/intel-rapl:0:0/energy_uj

If you don't have a screensaver installed, you will get the following error:

ERROR: Could not call Inhibit on org.freedesktop.ScreenSaver: No route to host
        org.freedesktop.DBus.Error.ServiceUnknown
        The name org.freedesktop.ScreenSaver was not provided by any .service files

You can disable the screensaver inhibiter to ignore these errors:

programs.gamemode.settings.general.inhibit_screensaver = 0;