diff --git a/daemon/main.c b/daemon/main.c index 7f89cb8..0be3eec 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -49,6 +49,7 @@ POSSIBILITY OF SUCH DAMAGE. #define _GNU_SOURCE +#include "config.h" #include "daemonize.h" #include "dbus_messaging.h" #include "gamemode.h" @@ -58,6 +59,17 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#define USAGE_TEXT \ + "Usage: %s [-d] [-l] [-h] [-v]\n\n" \ + " -d daemonize self after launch\n" \ + " -l log to syslog\n" \ + " -h print this help\n" \ + " -v print version\n" \ + "\n" \ + "See man page for more information.\n" + +#define VERSION_TEXT "gamemode version: v" GAMEMODE_VERSION "\n" + static void sigint_handler(__attribute__((unused)) int signo) { LOG_MSG("Quitting by request...\n"); @@ -79,7 +91,7 @@ int main(int argc, char *argv[]) bool daemon = false; bool use_syslog = false; int opt = 0; - while ((opt = getopt(argc, argv, "dl")) != -1) { + while ((opt = getopt(argc, argv, "dlvh")) != -1) { switch (opt) { case 'd': daemon = true; @@ -87,8 +99,16 @@ int main(int argc, char *argv[]) case 'l': use_syslog = true; break; + case 'v': + fprintf(stdout, VERSION_TEXT); + exit(EXIT_SUCCESS); + break; + case 'h': + fprintf(stdout, USAGE_TEXT, argv[0]); + exit(EXIT_SUCCESS); + break; default: - fprintf(stderr, "Usage: %s [-d] [-l]\n", argv[0]); + fprintf(stderr, USAGE_TEXT, argv[0]); exit(EXIT_FAILURE); break; } diff --git a/data/gamemoded.1 b/data/gamemoded.1 index 75c3b1e..ba0fbe7 100644 --- a/data/gamemoded.1 +++ b/data/gamemoded.1 @@ -1,10 +1,10 @@ .\" Manpage for gamemoded. .\" Contact linux-contact@feralinteractive.com to correct errors or typos. -.TH gamemoded 1 "23 Feb 2018" "0.3" "gamemoded man page" +.TH gamemoded 1 "6 March 2018" "0.3" "gamemoded man page" .SH NAME gamemoded \- optimises system performance on demand .SH SYNOPSIS -\fBgamemoded\fR [\fB\-d\fR] [\fB\-l\fR] +\fBgamemoded\fR [\fB\-d\fR] [\fB\-l\fR] [\fB\-h\fR] [\fB\-v\fR] .SH DESCRIPTION \fBGameMode\fR is a daemon/lib combo for Linux that allows games to request a set of optimisations be temporarily applied to the host OS. @@ -15,10 +15,16 @@ The design has a clear cut abstraction between the host daemon and library (\fBg .TP 8 .B \-d Run the daemon as a separate process (daemonize it) -.TP +.TP 8 .B \-l Log to syslog -.LP +.TP 8 +.B \-h +Print help text +.TP 8 +.B \-v +Print the version + .SH USAGE \fBlibgamemodeauto.so\fR can be pre-loaded into any program to request \fBgamemoded\fR begin or end the mode, like so: diff --git a/meson.build b/meson.build index ef9d972..949743f 100644 --- a/meson.build +++ b/meson.build @@ -66,9 +66,10 @@ path_polkit_action_dir = join_paths(path_datadir, 'polkit-1', 'actions') with_daemon = get_option('with-daemon') with_examples = get_option('with-examples') -# Provide config.h so the daemon knows where the helper is +# Provide a config.h cdata = configuration_data() cdata.set_quoted('LIBEXECDIR', path_libexecdir) +cdata.set_quoted('GAMEMODE_VERSION', meson.project_version()) config_h = configure_file( configuration: cdata, output: 'config.h',