Set up inhibit_screensaver config option to disable the feature

This commit is contained in:
Marc Di Luzio 2019-02-03 15:45:11 +00:00
parent 6a7aa1e307
commit ba49055519
4 changed files with 28 additions and 2 deletions

View File

@ -72,6 +72,8 @@ struct GameModeConfig {
char ioprio[CONFIG_VALUE_MAX]; char ioprio[CONFIG_VALUE_MAX];
long inhibit_screensaver;
long reaper_frequency; long reaper_frequency;
}; };
@ -168,6 +170,8 @@ static int inih_handler(void *user, const char *section, const char *name, const
valid = get_long_value(name, value, &self->renice); valid = get_long_value(name, value, &self->renice);
} else if (strcmp(name, "ioprio") == 0) { } else if (strcmp(name, "ioprio") == 0) {
valid = get_string_value(value, self->ioprio); valid = get_string_value(value, self->ioprio);
} else if (strcmp(name, "inhibit_screensaver") == 0) {
valid = get_long_value(name, value, &self->inhibit_screensaver);
} }
} else if (strcmp(section, "custom") == 0) { } else if (strcmp(section, "custom") == 0) {
/* Custom subsection */ /* Custom subsection */
@ -229,6 +233,7 @@ static void load_config_files(GameModeConfig *self)
memset(self->softrealtime, 0, sizeof(self->softrealtime)); memset(self->softrealtime, 0, sizeof(self->softrealtime));
self->renice = 4; /* default value of 4 */ self->renice = 4; /* default value of 4 */
self->reaper_frequency = DEFAULT_REAPER_FREQ; self->reaper_frequency = DEFAULT_REAPER_FREQ;
self->inhibit_screensaver = 1; /* Defaults to on */
/* /*
* Locations to load, in order * Locations to load, in order
@ -382,6 +387,16 @@ void config_get_reaper_thread_frequency(GameModeConfig *self, long *value)
memcpy_locked_config(self, value, &self->reaper_frequency, sizeof(long)); memcpy_locked_config(self, value, &self->reaper_frequency, sizeof(long));
} }
/*
* Gets the screensaver inhibit setting
*/
bool config_get_inhibit_screensaver(GameModeConfig *self)
{
long val;
memcpy_locked_config(self, &val, &self->inhibit_screensaver, sizeof(long));
return val == 1;
}
/* /*
* Get a set of scripts to call when gamemode starts * Get a set of scripts to call when gamemode starts
*/ */

View File

@ -89,6 +89,11 @@ bool config_get_client_blacklisted(GameModeConfig *self, const char *client);
*/ */
void config_get_reaper_thread_frequency(GameModeConfig *self, long *value); void config_get_reaper_thread_frequency(GameModeConfig *self, long *value);
/*
* Get whether we want to inhibit the screensaver (defaults to true)
*/
bool config_get_inhibit_screensaver(GameModeConfig *self);
/* /*
* Get a set of scripts to call when gamemode starts * Get a set of scripts to call when gamemode starts
*/ */

View File

@ -198,7 +198,8 @@ static void game_mode_context_enter(GameModeContext *self)
} }
/* Inhibit the screensaver */ /* Inhibit the screensaver */
game_mode_inhibit_screensaver(true); if (config_get_inhibit_screensaver(self->config))
game_mode_inhibit_screensaver(true);
} }
/** /**
@ -213,7 +214,8 @@ static void game_mode_context_leave(GameModeContext *self)
sd_notifyf(0, "STATUS=%sGameMode is currently deactivated.%s\n", "\x1B[1;36m", "\x1B[0m"); sd_notifyf(0, "STATUS=%sGameMode is currently deactivated.%s\n", "\x1B[1;36m", "\x1B[0m");
/* UnInhibit the screensaver */ /* UnInhibit the screensaver */
game_mode_inhibit_screensaver(false); if (config_get_inhibit_screensaver(self->config))
game_mode_inhibit_screensaver(false);
/* Reset the governer state back to initial */ /* Reset the governer state back to initial */
if (self->initial_cpu_mode[0] != '\0') { if (self->initial_cpu_mode[0] != '\0') {

View File

@ -21,6 +21,10 @@ renice = 4
; currently, only the best-effort class is supported thus you cannot set it here ; currently, only the best-effort class is supported thus you cannot set it here
ioprio = 0 ioprio = 0
; Sets whether gamemode will inhibit the screensaver when active
; Defaults to 1
inhibit_screensaver=1
[filter] [filter]
; If "whitelist" entry has a value(s) ; If "whitelist" entry has a value(s)
; gamemode will reject anything not in the whitelist ; gamemode will reject anything not in the whitelist