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)?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityI 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)?
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.
nice(1)
? Am I missing something?