0

I have few steam games. Right now I renice them manually.

sudo renice -n -20 -p $(pgrep csgo_linux64)

Is there a way I can automatically do that (using systemd rules or something)?

2
  • Simplest way: Write a wrapper script to start them, rename the old program or modify PATH so it doesn't find it, always start with wrapper script.
    – dirkt
    Apr 13, 2020 at 9:59
  • 1
    nice(1)? Am I missing something?
    – mosvy
    Apr 13, 2020 at 11:55

1 Answer 1

1

The following may have some security implications of which I'm unaware, but all of the suggestions could achieve an answer to the question.

I use gamemoderun which is available on a lot of Linux distributions. It can can perform a variety of tweeks relevant to games, including doing a nice. For steam I change each game's properties launch options to be:

__GL_THREADED_OPTIMIZATION=1 gamemoderun %command%

To obtain the necessary permissions for nice/renice I have a gamers Linux/UNIX group. I add the following entries in /etc/security/limits.conf to set a default for limit for everyone via the user group, and then to allow anyone in the gamer group to renice by up to -6 but with a system hard limit of -10:

# limits for gamers group in /etc/security/limits.conf
# set default and max prio for users who are members of the gamer group
@user           -       nice    0
@gamer          soft    nice    -6
@gamer          hard    nice    -10

I put myself in the gamers group (this takes effect on a new login or via the newgrp command).

With these limits set gamemoderun can read and set a desired renice value from /home/myself/.config/gamemode.ini and apply it on game startup.

The one issue I have is that steam proton games seem to lose affinity with the command that started them and don't get the appropriate new limits. One workaround for this issue is to start steam with gamemoderun so that all processes it starts will wind up with the same limits.

Another possibility would be to use reniced or schedtool which, as I understand it, renice on the fly by matching processes attributes via periodic scans of the system.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.