mirror of
https://github.com/FeralInteractive/gamemode.git
synced 2025-06-06 07:37:21 +02:00
Teach gamemoded the '-r' option
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
This commit is contained in:
parent
3ac1b681c4
commit
966c207a33
@ -53,6 +53,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "daemonize.h"
|
||||
#include "dbus_messaging.h"
|
||||
#include "gamemode.h"
|
||||
#include "gamemode_client.h"
|
||||
#include "logging.h"
|
||||
|
||||
#include <signal.h>
|
||||
@ -65,6 +66,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
"Usage: %s [-d] [-l] [-h] [-v]\n\n" \
|
||||
" -d daemonize self after launch\n" \
|
||||
" -l log to syslog\n" \
|
||||
" -r request gamemode and pause\n" \
|
||||
" -h print this help\n" \
|
||||
" -v print version\n" \
|
||||
"\n" \
|
||||
@ -94,7 +96,7 @@ int main(int argc, char *argv[])
|
||||
bool daemon = false;
|
||||
bool use_syslog = false;
|
||||
int opt = 0;
|
||||
while ((opt = getopt(argc, argv, "dlvh")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "dlrvh")) != -1) {
|
||||
switch (opt) {
|
||||
case 'd':
|
||||
daemon = true;
|
||||
@ -102,6 +104,19 @@ int main(int argc, char *argv[])
|
||||
case 'l':
|
||||
use_syslog = true;
|
||||
break;
|
||||
case 'r':
|
||||
if (gamemode_request_start() < 0) {
|
||||
fprintf(stderr, "gamemode request failed: %s\n", gamemode_error_string());
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
fprintf(stdout, "gamemode request succeeded...\n");
|
||||
|
||||
// Simply pause and wait for any signal
|
||||
pause();
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
case 'v':
|
||||
fprintf(stdout, VERSION_TEXT);
|
||||
exit(EXIT_SUCCESS);
|
||||
|
@ -32,9 +32,11 @@ executable(
|
||||
dep_threads,
|
||||
dep_systemd,
|
||||
inih_dependency,
|
||||
libdl,
|
||||
],
|
||||
include_directories: [
|
||||
config_h_dir,
|
||||
libgamemode_includes,
|
||||
],
|
||||
install: true,
|
||||
)
|
||||
|
@ -19,6 +19,9 @@ Run the daemon as a separate process (daemonize it)
|
||||
.B \-l
|
||||
Log to syslog
|
||||
.TP 8
|
||||
.B \-r
|
||||
Request gamemode and wait for any signal
|
||||
.TP 8
|
||||
.B \-h
|
||||
Print help text
|
||||
.TP 8
|
||||
|
Loading…
x
Reference in New Issue
Block a user