diff options
author | Ilia Bozhinov <ammen99@gmail.com> | 2020-05-18 13:07:29 +0200 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2020-05-20 17:21:59 +0200 |
commit | 72f28ed0b36e4f8a6a8732788bc557533ac36ab1 (patch) | |
tree | 235e07b514c553877680838a4eaefc42e5ab436b /examples | |
parent | 2176c63856df4e411df0ba3c5eee43f69e977b6e (diff) |
examples: make output-power-management oneshot by default
Diffstat (limited to 'examples')
-rw-r--r-- | examples/output-power-management.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/examples/output-power-management.c b/examples/output-power-management.c index 19bc8271..8d91c6c0 100644 --- a/examples/output-power-management.c +++ b/examples/output-power-management.c @@ -1,5 +1,6 @@ #define _POSIX_C_SOURCE 200809L #include <errno.h> +#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -72,7 +73,8 @@ static const struct wl_registry_listener registry_listener = { static const char usage[] = "usage: output-power-management [options...]\n" " -h: show this help message\n" " -e: turn outputs on\n" - " -d: turn outputs off\n"; + " -d: turn outputs off\n" + " -w: continuously watch for power mode changes\n"; int main(int argc, char *argv[]) { wl_list_init(&outputs); @@ -80,7 +82,8 @@ int main(int argc, char *argv[]) { int opt; enum zwlr_output_power_v1_mode mode = ZWLR_OUTPUT_POWER_V1_MODE_ON; - while ((opt = getopt(argc, argv, "edh")) != -1) { + bool watch_mode = false; + while ((opt = getopt(argc, argv, "edhw")) != -1) { switch (opt) { case 'e': mode = ZWLR_OUTPUT_POWER_V1_MODE_ON; @@ -88,6 +91,9 @@ int main(int argc, char *argv[]) { case 'd': mode = ZWLR_OUTPUT_POWER_V1_MODE_OFF; break; + case 'w': + watch_mode = true; + break; case 'h': default: fprintf(stderr, usage); @@ -126,6 +132,11 @@ int main(int argc, char *argv[]) { mode); } + if (!watch_mode) { + wl_display_roundtrip(display); + return EXIT_SUCCESS; + } + while (wl_display_dispatch(display) != -1) { // nothing to see here, please move along } |