Skip to content

Commit

Permalink
yutani-query: add quiet option
Browse files Browse the repository at this point in the history
  • Loading branch information
klange committed Nov 7, 2018
1 parent ace77ae commit 1604c43
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions apps/yutani-query.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <toaru/yutani.h>

yutani_t * yctx;
int quiet = 0;

void show_usage(int argc, char * argv[]) {
printf(
Expand All @@ -31,24 +32,35 @@ void show_usage(int argc, char * argv[]) {
}

int show_resolution(void) {
if (!yctx) {
if (!quiet) printf("(not connected)\n");
return 1;
}
printf("%dx%d\n", (int)yctx->display_width, (int)yctx->display_height);
return 0;
}

int main(int argc, char * argv[]) {
yctx = yutani_init();
int reload(void) {
if (!yctx) {
printf("(not connected)\n");
if (!quiet) printf("(not connected)\n");
return 1;
}
yutani_special_request(yctx, NULL, YUTANI_SPECIAL_REQUEST_RELOAD);
return 0;
}

int main(int argc, char * argv[]) {
yctx = yutani_init();
int opt;
while ((opt = getopt(argc, argv, "?re")) != -1) {
while ((opt = getopt(argc, argv, "?qre")) != -1) {
switch (opt) {
case 'q':
quiet = 1;
break;
case 'r':
return show_resolution();
case 'e':
yutani_special_request(yctx, NULL, YUTANI_SPECIAL_REQUEST_RELOAD);
return 0;
return reload();
case '?':
show_usage(argc,argv);
return 0;
Expand Down

0 comments on commit 1604c43

Please sign in to comment.