examples: make output-power-management oneshot by default

master
Ilia Bozhinov 5 years ago committed by Simon Ser
parent 2176c63856
commit 72f28ed0b3

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

Loading…
Cancel
Save