yutani-query.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. " -e \033[3mask compositor to reload extensions\033[0m\n"
  26. " -? \033[3mshow this help text\033[0m\n"
  27. "\n", argv[0]);
  28. }
  29. int show_resolution(void) {
  30. printf("%dx%d\n", (int)yctx->display_width, (int)yctx->display_height);
  31. return 0;
  32. }
  33. int main(int argc, char * argv[]) {
  34. yctx = yutani_init();
  35. if (!yctx) {
  36. printf("(not connected)\n");
  37. return 1;
  38. }
  39. int opt;
  40. while ((opt = getopt(argc, argv, "?re")) != -1) {
  41. switch (opt) {
  42. case 'r':
  43. return show_resolution();
  44. case 'e':
  45. yutani_special_request(yctx, NULL, YUTANI_SPECIAL_REQUEST_RELOAD);
  46. return 0;
  47. case '?':
  48. show_usage(argc,argv);
  49. return 0;
  50. }
  51. }
  52. return 0;
  53. }