status

statusbar program for dwm
git clone anongit@rnpnr.xyz:status.git
Log | Files | Refs | Feed | README | LICENSE

script.c (311B)


      1 /* See LICENSE for license details. */
      2 static size_t
      3 script(struct Block *b)
      4 {
      5 	FILE *fp;
      6 
      7 	if ((fp = popen(b->arg, "r")) == NULL)
      8 		die("popen()\n");
      9 
     10 	if (fgets(buf, sizeof(buf), fp) != NULL)
     11 		buf[strcspn(buf, "\n")] = 0;
     12 	pclose(fp);
     13 
     14 	return buf[0]? snprintf(b->curstr, LEN(b->curstr), b->fmt, buf) : 0;
     15 }