This commit is contained in:
Sascha Kruse 2011-09-08 00:40:20 +02:00
parent cc12987de6
commit 4bb529bfae
3 changed files with 50 additions and 10 deletions

11
README
View File

@ -5,8 +5,9 @@ SYNOPSIS
dunst [-b] [-fn font] [-nb color] [-nf color] [-to secs]
DESCRIPTION
dunst is a lightweight notification-daemon for the libnotify. It can also be used as a standalone notification system. Dnotify displays messages received via
dbus or as commandline argument in a fashion similar to dmenu and additionally prints them to stdout. Notifications can be closed via mouseclick.
dunst is a lightweight notification-daemon for the libnotify. It can also be used as a standalone notifica
tion system. Dnotify displays messages received via dbus or as commandline argument in a fashion similar to
dmenu and additionally prints them to stdout. Notifications can be closed via mouseclick.
OPTIONS
-h/--help
@ -14,6 +15,9 @@ OPTIONS
-b dunst appears at the bottom of the screen.
-ne l/r
Don't expand popup across the screen and put it in the [l]eft or [r]ight edge
-fn/ font
defines the font or font set used.
@ -33,7 +37,8 @@ AUTHOR
written by Sascha Kruse <knopwob@googlemail.com>
COPYRIGHT
Parts of the code are taken from dmenu (especially draw.c and draw.h). Read LICENCE.dmenu and look at http://tools.suckless.org/dmenu.
Parts of the code are taken from dmenu (especially draw.c and draw.h). Read LICENCE.dmenu and look at
http://tools.suckless.org/dmenu.
Some snippets in dunst_dbus.c are taken from twmn. See http://github.com/sboli/twmn.

View File

@ -24,6 +24,9 @@ display help message.
.B \-b
dunst appears at the bottom of the screen.
.TP
.BI \-ne " l/r"
Don't expand popup across the screen and put it in the [l]eft or [r]ight edge
.TP
.BI \-fn/ " font"
defines the font or font set used.
.TP

46
dunst.c
View File

@ -28,6 +28,8 @@ typedef struct _msg_queue_t {
/* global variables */
static int bh, mw, mh;
static int expand = False;
static int right = False;
static int lines = 0;
static const char *font = NULL;
static const char *normbgcolor = "#cccccc";
@ -98,13 +100,29 @@ pop(msg_queue_t *queue) {
void
drawmsg(const char *msg) {
int width, x, y;
int screen = DefaultScreen(dc->dpy);
dc->x = 0;
dc->y = 0;
dc->h = 0;
drawrect(dc, 0, 0, mw, mh, True, BG(dc, normcol));
y = topbar ? 0 : DisplayHeight(dc->dpy, screen) - mh;
if(expand) {
width = mw;
} else {
width = textw(dc, msg);
}
if(right) {
x = mw -width;
} else {
x = 0;
}
resizedc(dc, width, mh);
XResizeWindow(dc->dpy, win, width, mh);
drawrect(dc, 0, 0, width, mh, True, BG(dc, normcol));
drawtext(dc, msg, normcol);
XMoveWindow(dc->dpy, win, x, y);
mapdc(dc, win, mw, mh);
mapdc(dc, win, width, mh);
}
void
@ -258,10 +276,27 @@ main(int argc, char *argv[]) {
now = time(&now);
for(i = 1; i < argc; i++) {
/* switches */
if(!strcmp(argv[i], "-b"))
topbar = False;
else if(!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
else if(!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help"))
usage(EXIT_SUCCESS);
/* options */
else if(i == argc) {
printf("Option needs an argument\n");
usage(1);
}
else if(!strcmp(argv[i], "-ne")) {
expand = False;
if(!strcmp(argv[i+1], "l")) {
right = False;
} else if (!strcmp(argv[i+1], "r")) {
right = True;
} else {
usage(EXIT_FAILURE);
}
i++;
}
else if(!strcmp(argv[i], "-fn"))
font = argv[++i];
@ -272,9 +307,6 @@ main(int argc, char *argv[]) {
else if(!strcmp(argv[i], "-to"))
global_timeout = atoi(argv[++i]);
else if(!strcmp(argv[i], "-msg")) {
if(i+1 == argc) {
usage(EXIT_FAILURE);
}
msgqueuehead = append(msgqueuehead, argv[++i]);
loop = False;
}
@ -297,6 +329,6 @@ main(int argc, char *argv[]) {
void
usage(int exit_status) {
fputs("usage: dunst [-h/--help] [-b] [-fn font]\n[-nb/-bg color] [-nf/-fg color] [-to secs] [-msg msg]\n", stderr);
fputs("usage: dunst [-h/--help] [-b] [-ne l/r] [-fn font]\n[-nb/-bg color] [-nf/-fg color] [-to secs] [-msg msg]\n", stderr);
exit(exit_status);
}