noexpand
This commit is contained in:
parent
cc12987de6
commit
4bb529bfae
11
README
11
README
@ -5,8 +5,9 @@ SYNOPSIS
|
|||||||
dunst [-b] [-fn font] [-nb color] [-nf color] [-to secs]
|
dunst [-b] [-fn font] [-nb color] [-nf color] [-to secs]
|
||||||
|
|
||||||
DESCRIPTION
|
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
|
dunst is a lightweight notification-daemon for the libnotify. It can also be used as a standalone notifica‐
|
||||||
dbus or as commandline argument in a fashion similar to dmenu and additionally prints them to stdout. Notifications can be closed via mouseclick.
|
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
|
OPTIONS
|
||||||
-h/--help
|
-h/--help
|
||||||
@ -14,6 +15,9 @@ OPTIONS
|
|||||||
|
|
||||||
-b dunst appears at the bottom of the screen.
|
-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
|
-fn/ font
|
||||||
defines the font or font set used.
|
defines the font or font set used.
|
||||||
|
|
||||||
@ -33,7 +37,8 @@ AUTHOR
|
|||||||
written by Sascha Kruse <knopwob@googlemail.com>
|
written by Sascha Kruse <knopwob@googlemail.com>
|
||||||
|
|
||||||
COPYRIGHT
|
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.
|
Some snippets in dunst_dbus.c are taken from twmn. See http://github.com/sboli/twmn.
|
||||||
|
|
||||||
|
3
dunst.1
3
dunst.1
@ -24,6 +24,9 @@ display help message.
|
|||||||
.B \-b
|
.B \-b
|
||||||
dunst appears at the bottom of the screen.
|
dunst appears at the bottom of the screen.
|
||||||
.TP
|
.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"
|
.BI \-fn/ " font"
|
||||||
defines the font or font set used.
|
defines the font or font set used.
|
||||||
.TP
|
.TP
|
||||||
|
46
dunst.c
46
dunst.c
@ -28,6 +28,8 @@ typedef struct _msg_queue_t {
|
|||||||
|
|
||||||
/* global variables */
|
/* global variables */
|
||||||
static int bh, mw, mh;
|
static int bh, mw, mh;
|
||||||
|
static int expand = False;
|
||||||
|
static int right = False;
|
||||||
static int lines = 0;
|
static int lines = 0;
|
||||||
static const char *font = NULL;
|
static const char *font = NULL;
|
||||||
static const char *normbgcolor = "#cccccc";
|
static const char *normbgcolor = "#cccccc";
|
||||||
@ -98,13 +100,29 @@ pop(msg_queue_t *queue) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
drawmsg(const char *msg) {
|
drawmsg(const char *msg) {
|
||||||
|
int width, x, y;
|
||||||
|
int screen = DefaultScreen(dc->dpy);
|
||||||
dc->x = 0;
|
dc->x = 0;
|
||||||
dc->y = 0;
|
dc->y = 0;
|
||||||
dc->h = 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);
|
drawtext(dc, msg, normcol);
|
||||||
|
XMoveWindow(dc->dpy, win, x, y);
|
||||||
|
|
||||||
mapdc(dc, win, mw, mh);
|
mapdc(dc, win, width, mh);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -258,10 +276,27 @@ main(int argc, char *argv[]) {
|
|||||||
now = time(&now);
|
now = time(&now);
|
||||||
|
|
||||||
for(i = 1; i < argc; i++) {
|
for(i = 1; i < argc; i++) {
|
||||||
|
/* switches */
|
||||||
if(!strcmp(argv[i], "-b"))
|
if(!strcmp(argv[i], "-b"))
|
||||||
topbar = False;
|
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);
|
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"))
|
else if(!strcmp(argv[i], "-fn"))
|
||||||
font = argv[++i];
|
font = argv[++i];
|
||||||
@ -272,9 +307,6 @@ main(int argc, char *argv[]) {
|
|||||||
else if(!strcmp(argv[i], "-to"))
|
else if(!strcmp(argv[i], "-to"))
|
||||||
global_timeout = atoi(argv[++i]);
|
global_timeout = atoi(argv[++i]);
|
||||||
else if(!strcmp(argv[i], "-msg")) {
|
else if(!strcmp(argv[i], "-msg")) {
|
||||||
if(i+1 == argc) {
|
|
||||||
usage(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
msgqueuehead = append(msgqueuehead, argv[++i]);
|
msgqueuehead = append(msgqueuehead, argv[++i]);
|
||||||
loop = False;
|
loop = False;
|
||||||
}
|
}
|
||||||
@ -297,6 +329,6 @@ main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
usage(int exit_status) {
|
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);
|
exit(exit_status);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user