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.

31 lines
585 B

  1. static int dwmblockssig;
  2. pid_t dwmblockspid = 0;
  3. int
  4. getdwmblockspid()
  5. {
  6. char buf[16];
  7. FILE *fp = popen("pidof -s dwmblocks", "r");
  8. if (fgets(buf, sizeof(buf), fp));
  9. pid_t pid = strtoul(buf, NULL, 10);
  10. pclose(fp);
  11. dwmblockspid = pid;
  12. return pid != 0 ? 0 : -1;
  13. }
  14. void
  15. sigdwmblocks(const Arg *arg)
  16. {
  17. union sigval sv;
  18. sv.sival_int = (dwmblockssig << 8) | arg->i;
  19. if (!dwmblockspid)
  20. if (getdwmblockspid() == -1)
  21. return;
  22. if (sigqueue(dwmblockspid, SIGUSR1, sv) == -1) {
  23. if (errno == ESRCH) {
  24. if (!getdwmblockspid())
  25. sigqueue(dwmblockspid, SIGUSR1, sv);
  26. }
  27. }
  28. }