diff --git a/wlopm.1 b/wlopm.1 index 4bf0e0c..d905cc0 100644 --- a/wlopm.1 +++ b/wlopm.1 @@ -19,6 +19,11 @@ wlopm \- Wayland output power management .OP \-\-help .SY . +.SY wlopm +.OP \-v +.OP \-\-version +.SY +. . .SH DESCRIPTION .P @@ -36,6 +41,12 @@ Print help and exit. .RE . .P +\fB-v\fR, \fB--version\fR +.RS +Print version and exit. +.RE +. +.P \fB-j\fR, \fB--json\fR .RS Enable JSON formatting for listing outputs and errors encountered while trying diff --git a/wlopm.c b/wlopm.c index 880de9c..7366395 100644 --- a/wlopm.c +++ b/wlopm.c @@ -35,12 +35,13 @@ #include "wlr-output-power-management-unstable-v1.h" -#define VERSION "0.0.1" +#define VERSION "0.1.0" const char usage[] = "Usage: wlopm [options...]\n" " -j, --json Use JSON format.\n" " -h, --help Print this help text and exit.\n" + " -v, --version Print version and exit.\n" " --on Set the power mode of the specified output to on.\n" " --off Set the power mode of the specified output to off.\n" " --toggle Toggle the power mode of the specified output.\n" @@ -464,6 +465,14 @@ int main(int argc, char *argv[]) fputs(usage, stderr); return EXIT_SUCCESS; } + if ( strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0 ) + { + { + destroy_all_operations(); + fprintf(stderr, "wlopm version %s\n", VERSION); + return EXIT_SUCCESS; + } + } else if ( strcmp(argv[i], "-j") == 0 || strcmp(argv[i], "--json") == 0 ) json = true; else if ( strcmp(argv[i], "--on") == 0 )