toaruos/apps/yutani-query.c

65 lines
1.2 KiB
C
Raw Normal View History

2018-02-25 17:05:57 +03:00
#include <stdio.h>
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"
"usage: %s [-rfm?]\n"
"\n"
" -r \033[3mprint display resoluton\033[0m\n"
" -f \033[3mprint the name of the default font\033[0m\n"
" -m \033[3mprint the name of the monospace font\033[0m\n"
" -? \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;
}
#if 0
int show_fontname(int font) {
init_shmemfonts();
printf("%s\n", shmem_font_name(font));
return 0;
}
#endif
int main(int argc, char * argv[]) {
yctx = yutani_init();
if (!yctx) {
printf("(not connected)\n");
return 1;
}
if (argc > 1) {
for (int i = 1; i < argc; ++i) {
if (argv[i][0] == '-') {
char *c = &argv[i][1];
while (*c) {
switch (*c) {
case 'r':
return show_resolution();
#if 0
case 'f':
return show_fontname(FONT_SANS_SERIF);
case 'm':
return show_fontname(FONT_MONOSPACE);
#endif
case '?':
show_usage(argc, argv);
return 0;
}
c++;
}
}
}
}
return 0;
}