25 Commits

Author SHA1 Message Date
Marc Di Luzio
ad2c218ab3 Allow setting the device value with a hex string
Also stops erroring on 0 value longs
2019-02-12 08:55:23 +00:00
Marc Di Luzio
cee2351c55 Add config for vendor and device 2019-02-12 08:55:23 +00:00
Marc Di Luzio
b1bf33d386 Add config parameters for GPU clocking 2019-02-12 08:55:23 +00:00
Marc Di Luzio
ba49055519 Set up inhibit_screensaver config option to disable the feature 2019-02-03 15:45:11 +00:00
Kai Krakow
ebf177bebe daemon-config: Add ioprio configuration option
Signed-off-by: Kai Krakow <kai@kaishome.de>
2018-10-01 19:34:46 +02:00
Alex Smith
fdfc6edfd9 Comment out some sections in the example configuration file
Avoid potential issues if the config file is copied without modification.
2018-07-23 17:10:32 +01:00
Alex Smith
2ae86fabd6 Update to version 1.3-dev post-1.2 release 2018-07-21 09:48:40 +01:00
Kai Krakow
57c6bbb444 config: Allow renice configuration
This commit adds configuration support for the renice value and amends
documentation and examples. This commit by itself does nothing, the
following commit is needed to actually apply the new settings.

Signed-off-by: Kai Krakow <kai@kaishome.de>
2018-06-10 09:33:02 +02:00
Kai Krakow
9dfd718807 config: Introduce new setting "softrealtime"
This adds support for a new configuration option "softrealtime" to be
read from the general section. This commit alone does nothing, the
following commit adds actually making use of the value.

Signed-off-by: Kai Krakow <kai@kaishome.de>
2018-05-24 22:41:04 +02:00
Marc Di Luzio
fec4732740 Add an example .desktop file
As seen in Issue #45 (thanks OlliC)

This can be placed in ~/.local/share/applications/ to allow easier (re)launching of gamemode, in particular when the DISPLAY param is needed
2018-05-16 08:42:19 +01:00
Marc Di Luzio
5ebc77a0f1 Add defaultgov and desiredgov config settings
Allows users to choose which governor settings they want.

	Should provide some future compatibility for other governor settings.
2018-05-15 17:04:31 +01:00
Marc Di Luzio
d9072607d9 Label master as 1.2-dev 2018-05-11 14:53:30 +01:00
Marc Di Luzio
fb2f3c628a Update to 1.1 ready for release 2018-04-25 15:50:05 +01:00
Marc Di Luzio
d88168d39c Update the current example config file 2018-04-24 17:14:12 +01:00
Leonard
752d877196 Minor C cleanup (#27)
* Minor C cleanup

 - some symbols can be made static:
    1. set_gov_state
    2. everything in gamemode_client.h
 - daemonize() can also take a const char*, since the name is only
   passed to printf() or syslog()
 - prevent shadowing of variables
 - use explicit (void) as parameter-list more consistently
 - use some more const.
   Move cast to more appropriate place and document that execv() behaves
   as if args where of type const *char and we trust on that.
 - example: Just use main(void), which is also an acceptable ISO-C decl
 - example: Use stderr for errors

* Fix -Wold-style-declaration issue
2018-04-16 17:21:35 +01:00
grmat
66e805c481 doc/examples: remove 'ninja' as explicit dep (#4)
as it's already required by meson.
Also use the default unit file path (/usr/lib/systemd/user/) for
packaged versions. /etc/systemd/user is intended for manually installed
services.

arch-meson is just a Meson wrapper with correct arch packaging prefixes set.
2018-04-13 10:28:00 +01:00
Ikey Doherty
69db9c2a61 Conformance: Update copyright range to include 2018
Signed-off-by: Ikey Doherty <ikey@solus-project.com>
2018-04-10 13:23:38 +01:00
Marc Di Luzio
4f14c807ba 1.0: Finalised for release
Updating the README.md to bring it ready for wider release:
* Removed some points that were more implementation details
* Added Contributions section
* Simplified the usage section
* Expanded initial explanation
* Fixed steam launch command to allow the overlay to still work

Others:
* Mark as 1.0
* Update the license file for 2018
2018-04-04 10:06:23 +01:00
Marc Di Luzio
759cbc3c40 Add config file parsing
Checks for a gamemode.ini in /usr/share/gamemode/ (or in the cwd for debugging)

	Currently allows for blacklisting and whitelisting clients based on rudimentary needle-haystack executable name checks

	See the example/gamemode.ini file for expected syntax

	Using the BSD licensed inih library (with additional meson.build file)
2018-03-23 16:59:15 +00:00
Minze Zwerver
24a192d594 Added an example PKBUILD file for Arch 2018-03-23 16:59:15 +00:00
Ikey Doherty
e90bd98d64 Enforce strict compiler warnings
This exposed a bunch of issues that needed dealing with to ensure the
code is clean and sane. Notably the dlopen/dlsym routine has been altered
to closer match the LSI approach of safe symbol binding, by not attempting
to directly cast the result of a dlsym operation. Instead, if we succeed
in getting the dlsym() pointer, we memcpy this to the target and ensure
we have the correct constraints.

Note that in sanitizing the log helpers, I opted to remove the varargs
ability from FATAL_ERRNO given this is used exactly like perror() and
there are no examples currently using varargs with this in the tree.
This allowed me to keep the log helpers as macros and not have to implement
wrapper functions.

Signed-off-by: Ikey Doherty <ikey@solus-project.com>
2018-03-05 17:32:26 +00:00
Ikey Doherty
68e326de60 Transform into a full D-BUS service with Polkit support
Primarily we convert the service into a thread safe one that isn't reliant
on signaling for control flow, eliminating data race conditions. We also
enable interleaving by separating game mode pivoting from explicit client
registration.

The static pid list is now converted into a dynamic list that is OOM safe
to store all registered clients (with a reasonable upper limit of 256 clients)
to better handle cases where LD_PRELOAD is used for a large process group.
Additionally we begin storing some metadata on the connected clients such
as their executable path, which will enable us to perform some basic
whitelisting in future.

The cpugovctl binary is now moved into the libexecdir as an explicit helper
of the D-BUS service, using the shared library to merge some code back into
the daemon. This saves having to execute a process to query the state of the
governors, as we don't need a privileged client to do this.

In order to sanely set the governors, we require that the binary is running
as euid 0, and execute this using `pkexec`. A PolKit policy definition is
provided which allows active/logged in users to execute this helper through
a path whitelist. As such we can convert the daemon into user-mode only, with
the privileged helper being dispatched exclusively via polkit. This removes
the need for a setuid helper or having a system mode daemon.

Lastly we clean up the codebase a bit to be consistent with modern C code
conventions, using pragmas where available. The library component still uses
the older ifdef approach to support older compilers, but the daemon portion
uses the directive to simplify intent and speed up compilation. Additionally
we move all comments to C style comments for consistency, instead of mixing
in C++ style single line comments, in order to establish a formal coding
style.

The net result is a more robust service which can be D-BUS activated when
clients need it, that can perform scaling automatically without harassing
the user with authentication popups.

Signed-off-by: Ikey Doherty <ikey@solus-project.com>
2018-03-05 17:32:25 +00:00
Ikey Doherty
1328e07f86 Split meson up to be more modular
This also explicitly constructs reusable library components to make it
easier to extend the project over time. Notably we make less assumptions
about the host system and use pkgconfig where appropriate to give us
system details, such as the systemd system unit directory for packaging.
This can be overriden with the meson option.

Signed-off-by: Ikey Doherty <ikey@solus-project.com>
2018-03-05 17:32:01 +00:00
Marc Di Luzio
2bbaab129b Apply clang format to files
Also add brackets for all scopes at the same time
2018-03-05 17:32:01 +00:00
Marc Di Luzio
c459c05076 Initial 0.1 commit
This is a small daemon/libary to enable games to request a
performance "game mode" from the system.

Currently only implemented to upgrade the CPU governor and
automatically downgrade it once done.

A game only needs to load libgamemodeauto to activate the request.
Which means an LD_PRELOAD can be applied to any game to activate
the mode as needed.

However gamemode_client.h can be used to manually activate/deactivate
the mode as needed, and also perform error checking.

The libs are miminal loaders to call into an installed libgamemode
which, if the daemon is installed and running, will send through
the equivelant game mode request, and magic will happen.

See the README.md for more details.

Currently licensed under the BSD 3 clause license.
2018-03-05 17:32:01 +00:00