yutani-query.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* vim: tabstop=4 shiftwidth=4 noexpandtab
  2. * This file is part of ToaruOS and is released under the terms
  3. * of the NCSA / University of Illinois License - see LICENSE.md
  4. * Copyright (C) 2015-2018 K. Lange
  5. *
  6. * yutani-query - Query display server information
  7. *
  8. * At the moment, this only supports querying the display
  9. * resolution. An older version of this application had
  10. * support for getting the default font names, but the
  11. * font server is no longer part of the compositor, so
  12. * that functionality doesn't make sense here.
  13. */
  14. #include <stdio.h>
  15. #include <unistd.h>
  16. #include <toaru/yutani.h>
  17. yutani_t * yctx;
  18. void show_usage(int argc, char * argv[]) {
  19. printf(
  20. "yutani-query - show misc. information about the display system\n"
  21. "\n"
  22. "usage: %s [-r?]\n"
  23. "\n"
  24. " -r \033[3mprint display resoluton\033[0m\n"
  25. " -? \033[3mshow this help text\033[0m\n"
  26. "\n", argv[0]);
  27. }
  28. int show_resolution(void) {
  29. printf("%dx%d\n", (int)yctx->display_width, (int)yctx->display_height);
  30. return 0;
  31. }
  32. int main(int argc, char * argv[]) {
  33. yctx = yutani_init();
  34. if (!yctx) {
  35. printf("(not connected)\n");
  36. return 1;
  37. }
  38. int opt;
  39. while ((opt = getopt(argc, argv, "?r")) != -1) {
  40. switch (opt) {
  41. case 'r':
  42. return show_resolution();
  43. case '?':
  44. show_usage(argc,argv);
  45. return 0;
  46. }
  47. }
  48. return 0;
  49. }