yutani-query.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #include <stdio.h>
  2. #include <getopt.h>
  3. #include <toaru/yutani.h>
  4. yutani_t * yctx;
  5. void show_usage(int argc, char * argv[]) {
  6. printf(
  7. "yutani-query - show misc. information about the display system\n"
  8. "\n"
  9. "usage: %s [-rfm?]\n"
  10. "\n"
  11. " -r \033[3mprint display resoluton\033[0m\n"
  12. " -f \033[3mprint the name of the default font\033[0m\n"
  13. " -m \033[3mprint the name of the monospace font\033[0m\n"
  14. " -? \033[3mshow this help text\033[0m\n"
  15. "\n", argv[0]);
  16. }
  17. int show_resolution(void) {
  18. printf("%dx%d\n", yctx->display_width, yctx->display_height);
  19. return 0;
  20. }
  21. #if 0
  22. int show_fontname(int font) {
  23. init_shmemfonts();
  24. printf("%s\n", shmem_font_name(font));
  25. return 0;
  26. }
  27. #endif
  28. int main(int argc, char * argv[]) {
  29. yctx = yutani_init();
  30. if (!yctx) {
  31. printf("(not connected)\n");
  32. return 1;
  33. }
  34. if (argc > 1) {
  35. for (int i = 1; i < argc; ++i) {
  36. if (argv[i][0] == '-') {
  37. char *c = &argv[i][1];
  38. while (*c) {
  39. switch (*c) {
  40. case 'r':
  41. return show_resolution();
  42. #if 0
  43. case 'f':
  44. return show_fontname(FONT_SANS_SERIF);
  45. case 'm':
  46. return show_fontname(FONT_MONOSPACE);
  47. #endif
  48. case '?':
  49. show_usage(argc, argv);
  50. return 0;
  51. }
  52. c++;
  53. }
  54. }
  55. }
  56. }
  57. return 0;
  58. }