Honor prefix for installing gamemoderun to properly work in cross
environment so it can be installed in e.g. /usr/x86_64-pc-linux-gnu/bin
instead of /usr/bin like it's already done for gamemoded.
The install_mode option was only added in Meson 0.47. In versions prior
to that, it will base the mode on the permissions of the source file,
so set this executable to be compatible with older versions.
See #115.
This should remove a point of failure currently where users fail to set LD_PRELOAD correctly, or the path is wrong somehow.
FWIW: The old method still works, and I've noted that in the README.
This adds 10-gamemode.conf as a limits.d configuration file and with-pam-group meson option to allow renicing as an unpriviledged user being part of the specified group.
Signed-off-by: Térence Clastres <t.clastres@gmail.com>
Signed-off-by: Kai Krakow <kai@kaishome.de>
Always install the dbus service file and specify the systemd
unit file in it. This makes the service dbus-activatable and
thus we don't need to explicitly enable it (also we have one
less daemon running, if it is not needed).
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>
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>
gamemoded will now load and merge settings from the following locations - arrays will merge and single settings will overwrite.
1. /usr/share/gamemode/
2. /etc/
3. $XDG_CONFIG_HOME or $HOME/.config/
4. $PWD
This allows the client to query the daemon about the status of gamemode.
Returns the following:
0 if gamemode is inactive
1 if gamemode is active
2 if gamemode is active and this client is registered
-1 if the query failed
Passing -s to gamemoded will simply query and print the current status.
Allows for more comprehensive testing when using 'gamemoded -r' as well as more reactionary program behaviour
This allows for easy requesting of gamemode and pausing for any signal
Primarily useful for simple tests, but also functionally to allow enterning and exiting gamemode manually
A much requested feature, this allows for providing custom scripts in the config file. An example in the man page is below and would trigger both a system notification, and allow control over a background crypto mining script automatically in gamemode.
[custom]
; Custom scripts (executed using the shell) when gamemode starts and ends
start=notify-send "GameMode started"
/home/me/bin/stop_ethmining.sh
end=notify-send "GameMode ended"
/home/me/bin/start_ethmining.sh
Scripts are run with system() and do not have any special privilages, as with the rest of the daemon, custom scripts that require root will need their own permissions set up externally.
This commit also renames two defines as they needed to be moved to the public interface.
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
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)
Currently this will switch the build system between using a plain D-BUS
service file, or a user controllable systemd unit that can be actively
stopped/started.
In most cases it is more desirable to use the systemd unit approach,
as plain D-BUS services cannot be controlled and are more difficult
to introspect via the log.
For fallback cases we'll have the plain D-BUS unit, and in future we
can use this to allow untying from systemd specifics.
Signed-off-by: Ikey Doherty <ikey@solus-project.com>
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>
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>