My slstatus configuration
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 

27 rader
415 B

  1. #include <err.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include "util.h"
  5. const char *
  6. run_command(const char *cmd)
  7. {
  8. char *p;
  9. FILE *fp;
  10. fp = popen(cmd, "r");
  11. if (fp == NULL) {
  12. warn("Failed to get command output for %s", cmd);
  13. return NULL;
  14. }
  15. p = fgets(buf, sizeof(buf) - 1, fp);
  16. pclose(fp);
  17. if (!p)
  18. return NULL;
  19. if ((p = strrchr(buf, '\n')) != NULL)
  20. p[0] = '\0';
  21. return buf[0] ? buf : NULL;
  22. }