Add support for user defined local script plugins

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.
This commit is contained in:
Marc Di Luzio
2018-04-24 16:52:53 +01:00
parent c45b9f90a4
commit db8a70b7ba
5 changed files with 109 additions and 21 deletions

View File

@@ -32,6 +32,13 @@ POSSIBILITY OF SUCH DAMAGE.
#include <stdbool.h>
/*
* Maximum sizes values in a config list
* In practice inih has a INI_MAX_LINE value of 200 so the length is just a safeguard
*/
#define CONFIG_LIST_MAX 32
#define CONFIG_VALUE_MAX 256
/*
* Opaque config context type
*/
@@ -75,3 +82,14 @@ bool config_get_client_blacklisted(GameModeConfig *self, const char *client);
* Get the frequency (in seconds) for the reaper thread
*/
long config_get_reaper_thread_frequency(GameModeConfig *self);
/*
* Get a set of scripts to call when gamemode starts
*/
void config_get_gamemode_start_scripts(GameModeConfig *self,
char scripts[CONFIG_LIST_MAX][CONFIG_VALUE_MAX]);
/*
* Get a set of scripts to call when gamemode ends
*/
void config_get_gamemode_end_scripts(GameModeConfig *self,
char scripts[CONFIG_LIST_MAX][CONFIG_VALUE_MAX]);