Introduction
Introduction Statistics Contact Development Disclaimer Help
fifo.c - sites - public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log
Files
Refs
---
fifo.c (835B)
---
1 /*
2 * send anything in dwm status bar with fifo
3 * example : echo "hello" >> /tmp/dwm.fifo
4 * Author: Xavier Cartron (XC), [email protected]
5 */
6
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <string.h>
10 #include <fcntl.h>
11 #include <sys/types.h>
12 #include <sys/stat.h>
13
14 #define FIFO "/tmp/dwm.fifo"
15
16 char *
17 snotif()
18 {
19 char buf[BUFSIZ];
20 int len = 0;
21
22 int f = open(FIFO, O_NONBLOCK | O_RDWR);
23 if (f == -1){
24 return smprintf("%s","");
25 }
26
27 len = read(f, buf, sizeof(buf));
28 if (len == -1){
29 perror("fifo read");
30 close(f);
31 return smprintf("%s","");
32 }
33 close(f);
34
35 buf[len-1] = ' ';
36
37 return smprintf("%s",buf);
38 }
39
40 int
41 main(void)
42 {
43 int ret = 0;
44 ret = mkfifo(FIFO, ACCESSPERMS);
45 if (ret == -1) perror("fifo creation");
46
47 // your code
48
49 return 0;
50 }
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.