Another copy of my dotfiles. Because I don't completely trust GitHub.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.1 KiB

  1. int
  2. fake_signal(void)
  3. {
  4. char fsignal[256];
  5. char indicator[9] = "fsignal:";
  6. char str_signum[16];
  7. int i, v, signum;
  8. size_t len_fsignal, len_indicator = strlen(indicator);
  9. // Get root name property
  10. if (gettextprop(root, XA_WM_NAME, fsignal, sizeof(fsignal))) {
  11. len_fsignal = strlen(fsignal);
  12. // Check if this is indeed a fake signal
  13. if (len_indicator > len_fsignal ? 0 : strncmp(indicator, fsignal, len_indicator) == 0) {
  14. memcpy(str_signum, &fsignal[len_indicator], len_fsignal - len_indicator);
  15. str_signum[len_fsignal - len_indicator] = '\0';
  16. // Convert string value into managable integer
  17. for (i = signum = 0; i < strlen(str_signum); i++) {
  18. v = str_signum[i] - '0';
  19. if (v >= 0 && v <= 9) {
  20. signum = signum * 10 + v;
  21. }
  22. }
  23. // Check if a signal was found, and if so handle it
  24. if (signum)
  25. for (i = 0; i < LENGTH(signals); i++)
  26. if (signum == signals[i].signum && signals[i].func)
  27. signals[i].func(&(signals[i].arg));
  28. // A fake signal was sent
  29. return 1;
  30. }
  31. }
  32. // No fake signal was sent, so proceed with update
  33. return 0;
  34. }