فهرست منبع

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
Marc Di Luzio 6 سال پیش
والد
کامیت
966c207a33
3فایلهای تغییر یافته به همراه21 افزوده شده و 1 حذف شده
  1. 16 1
      daemon/main.c
  2. 2 0
      daemon/meson.build
  3. 3 0
      data/gamemoded.1

+ 16 - 1
daemon/main.c

@@ -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);

+ 2 - 0
daemon/meson.build

@@ -32,9 +32,11 @@ executable(
         dep_threads,
         dep_systemd,
         inih_dependency,
+        libdl,
     ],
     include_directories: [
         config_h_dir,
+        libgamemode_includes,
     ],
     install: true,
 )

+ 3 - 0
data/gamemoded.1

@@ -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