sites

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit c0caee8b9bb9e26a7db021e87f01dd99f109c415
parent 3d3022411cceca6b439b8bbffdef23a7e0db15bf
Author: Thuban <thuban@singularity.fr>
Date:   Fri, 21 Jun 2013 15:01:05 +0200

fifo for dwmstatus. Please correct it, or throw stones.

Diffstat:
Adwm.suckless.org/dwmstatus/fifo.c | 41+++++++++++++++++++++++++++++++++++++++++
Mdwm.suckless.org/dwmstatus/index.md | 2++
2 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/dwm.suckless.org/dwmstatus/fifo.c b/dwm.suckless.org/dwmstatus/fifo.c @@ -0,0 +1,41 @@ +/* + * send anything in dwm status bar with fifo + * example : echo "hello" >> /tmp/dwm.fifo + * Author: Xavier Cartron (XC), thuban@yeuxdelibad.net +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <fcntl.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <errno.h> + +#define FIFO "/tmp/dwm.fifo" + +char * +snotif() +{ + char buf[BUFSIZ]; + buf[0] = '\0'; + + int f = open(FIFO, O_RDONLY | O_NONBLOCK); + if (f == -1){ + perror("fifo opening"); + return smprintf("%s",""); + } + + if (read(f, buf, sizeof(buf) ) == -1){ + perror("fifo read"); + return smprintf("%s",""); + } + close(f); + + buf[strlen(buf)-1] = '\0'; + + return smprintf("%s",buf); +} + + + diff --git a/dwm.suckless.org/dwmstatus/index.md b/dwm.suckless.org/dwmstatus/index.md @@ -42,6 +42,8 @@ add them here as file or as code example. /tmp/dwmbuf. * [Simple function to have uptime](uptime.c) * [Simple function to have mpd title/artist info](mpdstatus.c) +* [Print any info in dwm status bar via fifo](fifo.c). Replaces + dynamic_info. Questions ---------