toaruos/apps/yutani-query.c

60 lines
1.5 KiB
C
Raw Normal View History

2018-08-14 11:13:38 +03:00
/* vim: tabstop=4 shiftwidth=4 noexpandtab
* This file is part of ToaruOS and is released under the terms
* of the NCSA / University of Illinois License - see LICENSE.md
* Copyright (C) 2015-2018 K. Lange
*
* yutani-query - Query display server information
*
* At the moment, this only supports querying the display
* resolution. An older version of this application had
* support for getting the default font names, but the
* font server is no longer part of the compositor, so
* that functionality doesn't make sense here.
*/
2018-02-25 17:05:57 +03:00
#include <stdio.h>
2018-08-08 12:15:34 +03:00
#include <unistd.h>
2018-02-25 17:05:57 +03:00
2018-03-19 05:38:11 +03:00
#include <toaru/yutani.h>
2018-02-25 17:05:57 +03:00
yutani_t * yctx;
void show_usage(int argc, char * argv[]) {
printf(
"yutani-query - show misc. information about the display system\n"
"\n"
2018-08-08 05:46:10 +03:00
"usage: %s [-r?]\n"
2018-02-25 17:05:57 +03:00
"\n"
" -r \033[3mprint display resoluton\033[0m\n"
" -e \033[3mask compositor to reload extensions\033[0m\n"
2018-02-25 17:05:57 +03:00
" -? \033[3mshow this help text\033[0m\n"
"\n", argv[0]);
}
int show_resolution(void) {
2018-04-25 08:03:29 +03:00
printf("%dx%d\n", (int)yctx->display_width, (int)yctx->display_height);
2018-02-25 17:05:57 +03:00
return 0;
}
int main(int argc, char * argv[]) {
yctx = yutani_init();
if (!yctx) {
printf("(not connected)\n");
return 1;
}
2018-08-08 05:46:10 +03:00
int opt;
while ((opt = getopt(argc, argv, "?re")) != -1) {
2018-08-08 05:46:10 +03:00
switch (opt) {
case 'r':
return show_resolution();
case 'e':
yutani_special_request(yctx, NULL, YUTANI_SPECIAL_REQUEST_RELOAD);
return 0;
2018-08-08 05:46:10 +03:00
case '?':
show_usage(argc,argv);
return 0;
2018-02-25 17:05:57 +03:00
}
}
return 0;
}