nfy

Minimal and daemonless notification program for X
git clone git://git.christosmarg.xyz/nfy.git
Log | Files | Refs | README | LICENSE

commit eb435af87ca87831003675138764932e9aa2fd12
parent 2ea859e1c31d6071fd9597628f53439b46b679a4
Author: Christos Margiolis <christos@margiolis.net>
Date:   Wed, 27 Jan 2021 16:16:10 +0200

added non-blocking behaviour

Diffstat:
MREADME | 4+++-
Mnfy.1 | 17+++++++++++++++--
Mnfy.c | 14++++++++++++++
3 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/README b/README @@ -20,4 +20,6 @@ setup and preferences. nfy will be installed in /usr/local/bin by default. Configuration is done by editing config.h and recompiling -the source code. Read the manpage for more. +the source code. + +Read the manpage for more. diff --git a/nfy.1 b/nfy.1 @@ -1,4 +1,4 @@ -.Dd nfy\-VERSRION +.Dd nfy\-VERSION .Dt NFY 1 .Os .Sh NAME @@ -8,18 +8,31 @@ .Nm .Ar str... .Sh DESCRIPTION +.Pp .Nm creates a temporary notification popup window and displays all the arguments that were passed to it. It uses the .Xr Xft 3 library to render fonts and colors, and .Xr Xrandr 3 -to handle screen sizes. All configuration is done by +to handle screen sizes. +.Pp +All configuration is done by editing the 'config.h' file in the source code. .Sh USAGE +.Pp If the string is not surrounded in quotes, .Nm will print one line for each word. +.Pp +.Nm +has a non-blocking behaviour, meaning that commands +coming after it can execute normally without them having +to wait for +.Nm +to finish first. This is helpful since it's a notification +program and there's no reason to wait for the notification +to die off before other commands can execute. .Sh SIGNALS .Nm handles only SIGALRM, SIGTERM and SIGINT. It receives a diff --git a/nfy.c b/nfy.c @@ -56,6 +56,7 @@ main(int argc, char *argv[]) XRRScreenResources *screens; XRRCrtcInfo *info = NULL; struct sigaction sig; + pid_t pid; int scr, scrw, scrh; int x, y, w, h, th; int i, j, len; @@ -66,6 +67,18 @@ main(int argc, char *argv[]) if (!(dpy = XOpenDisplay(NULL))) die("cannot open display"); + pid = fork(); + if (pid < 0) + die("fork:"); + if (pid > 0) + exit(EXIT_SUCCESS); + umask(0); + if (setsid() < 0) + die("setsid:"); + close(STDIN_FILENO); + close(STDOUT_FILENO); + close(STDERR_FILENO); + scr = DefaultScreen(dpy); screens = XRRGetScreenResources(dpy, RootWindow(dpy, scr)); info = XRRGetCrtcInfo(dpy, screens, screens->crtcs[0]); @@ -133,6 +146,7 @@ main(int argc, char *argv[]) sigaction(SIGALRM, &sig, 0); sigaction(SIGTERM, &sig, 0); sigaction(SIGINT, &sig, 0); + /* XXX: replace with just singal? */ if (duration > 0) alarm(duration);