My slstatus configuration
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

32 linhas
503 B

  1. /* See LICENSE file for copyright and license details. */
  2. #include <errno.h>
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include "../util.h"
  6. const char *
  7. run_command(const char *cmd)
  8. {
  9. char *p;
  10. FILE *fp;
  11. if (!(fp = popen(cmd, "r"))) {
  12. warn("popen '%s':", cmd);
  13. return NULL;
  14. }
  15. p = fgets(buf, sizeof(buf) - 1, fp);
  16. if (pclose(fp) < 0) {
  17. warn("pclose '%s':", cmd);
  18. return NULL;
  19. }
  20. if (!p) {
  21. return NULL;
  22. }
  23. if ((p = strrchr(buf, '\n'))) {
  24. p[0] = '\0';
  25. }
  26. return buf[0] ? buf : NULL;
  27. }