Nav apraksta

Marc Di Luzio d9727e9d38 Rename variables and functions that had an underscore prefix 7 gadi atpakaļ
daemon 752d877196 Minor C cleanup (#27) 7 gadi atpakaļ
data 6b71edf740 Integrated sd_notify to get status messages in systemd (#28) 7 gadi atpakaļ
example 752d877196 Minor C cleanup (#27) 7 gadi atpakaļ
lib d9727e9d38 Rename variables and functions that had an underscore prefix 7 gadi atpakaļ
scripts 1f12bcb892 Add a basic travis file for unit tests 7 gadi atpakaļ
subprojects 17efeaa699 subprojects: Switch inih to a properly managed git submodule 7 gadi atpakaļ
.clang-format ee1c51d0b0 Add clang format file 7 gadi atpakaļ
.gitignore 17efeaa699 subprojects: Switch inih to a properly managed git submodule 7 gadi atpakaļ
.gitmodules 17efeaa699 subprojects: Switch inih to a properly managed git submodule 7 gadi atpakaļ
.travis.yml 1f12bcb892 Add a basic travis file for unit tests 7 gadi atpakaļ
CHANGELOG 4f14c807ba 1.0: Finalised for release 7 gadi atpakaļ
LICENSE.txt 4f14c807ba 1.0: Finalised for release 7 gadi atpakaļ
README.md 66e805c481 doc/examples: remove 'ninja' as explicit dep (#4) 7 gadi atpakaļ
bootstrap.sh 8dfbaba288 Prevent running bootstrap.sh as root 7 gadi atpakaļ
meson.build 4f14c807ba 1.0: Finalised for release 7 gadi atpakaļ
meson_options.txt 7f26122c62 Allow controlling whether systemd is used or not 7 gadi atpakaļ

README.md

GameMode

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

The design has a clear-cut abstraction between the host daemon and library (gamemoded and libgamemode), and the client loaders (libgamemodeauto and gamemode_client.h) that allows for safe use without worrying about whether the daemon is installed or running. This design also means that while the host library currently relies on systemd for exchanging messages with the daemon, it's entirely possible to implement other internals that still work with the same clients.

GameMode was designed primarily as a stop-gap solution to problems with the Intel and AMD CPU powersave or ondemand governors, but is intended to be expanded beyond just CPU governor states, as there are a wealth of automation tasks one might want to apply.

Issues with GameMode should be reported here in the issues section, and not reported to Feral directly.


Building and installing

If your distribution already has GameMode packaged, it is preferable to install it directly from there. There are Solus and AUR packages already available.

GameMode depends on meson for building and systemd for internal communication. This repo contains a bootstrap.sh script to allow for quick install to the user bus, but check meson_options.txt for custom settings.

# Ubuntu
apt install meson libsystemd-dev pkg-config ninja-build
# Arch
pacman -S meson systemd
# Fedora
dnf install meson systemd-devel pkg-config

wget https://github.com/FeralInteractive/gamemode/archive/1.0.tar.gz && tar -xvf 1.0.tar.gz
cd gamemode-1.0
./bootstrap.sh

Requesting GameMode

Users

After installing libgamemodeauto.so simply preload it into the game:

LD_PRELOAD=/usr/\$LIB/libgamemodeauto.so ./game

Or edit the steam launch options:

LD_PRELOAD=$LD_PRELOAD:/usr/\$LIB/libgamemodeauto.so %command%

Developers

You may want to build the request directly into an app. Note that none of these client methods force your users to have the daemon installed or running - they will safely no-op if the host is missing.

// Manually with error checking
#include "gamemode_client.h"

	if( gamemode_request_start() < 0 ) {
		fprintf( stderr, "gamemode request failed: %s\n", gamemode_error_string() );
	}

	/* run game... */

	gamemode_request_end(); // Not required, gamemoded can clean up after game exits
// Automatically on program start and finish
#define GAMEMODE_AUTO
#include "gamemode_client.h"

Or, distribute libgamemodeauto.so and either add -lgamemodeauto to your linker arguments, or add it to an LD_PRELOAD in a launch script.


Components

gamemoded runs in the background, activates game mode on request, refcounts and also checks caller PID lifetime. Accepts -d (daemonize) and -l (log to syslog).

libgamemode is an internal library used to dispatch requests to the daemon. Note: libgamemode should never be linked with directly.

libgamemodeauto is a simple dynamic library that automatically requests game mode when loaded. Useful to LD_PRELOAD into any game as needed.

gamemode_client.h is as single header lib that lets a game request game mode and handle errors.


Configuration

The daemon can currently be configured using a gamemode.ini file in /usr/share/gamemode/. It will load the file when starting up. An example of what the file could look like is found in the example directory.

The file parsing uses inih.


Contributions

Pull Requests

Pull requests must match with the coding style found in the .clang-format file, please run this before commiting:

clang-format -i $(find . -name '*.[ch]')

Planned Features

  • Additional mode-switch plugins
  • User configuration for local mode-switch plugins
  • Improved client state tracking (PID is unreliable)
  • API to query if game mode is active

Maintained by

Marc Di Luzio (Feral Interactive)

See the contributors section for an extended list of contributors.


License

Copyright © 2018 Feral Interactive

GameMode is available under the terms of the BSD 3-Clause License (Revised)