diff --git a/config.def.h b/config.def.h index 1dd309e..cd702de 100644 --- a/config.def.h +++ b/config.def.h @@ -18,6 +18,7 @@ int indicate_hidden = True; /* show count of hidden messages */ int idle_threshold = 0; /* don't timeout notifications when idle for x seconds */ int show_age_threshold = -1; /* show age of notification, when notification is older than x seconds */ enum alignment align = left; /* text alignment [left/center/right] */ +float bounce_freq = 1; /* determines the bounce frequency (if activated) */ int sticky_history = True; int verbosity = 0; int word_wrap = False; diff --git a/config.mk b/config.mk index 4cbe378..b7fecf1 100644 --- a/config.mk +++ b/config.mk @@ -23,7 +23,7 @@ INIFLAGS = -DINI_ALLOW_MULTILINE=0 # includes and libs INCS = -I${X11INC} $(shell pkg-config --cflags dbus-1 libxdg-basedir) ${XFTINC} -LIBS = -L${X11LIB} -lX11 -lXss ${XFTLIBS} ${XINERAMALIBS} $(shell pkg-config --libs dbus-1 libxdg-basedir) +LIBS = -lm -L${X11LIB} -lX11 -lXss ${XFTLIBS} ${XINERAMALIBS} $(shell pkg-config --libs dbus-1 libxdg-basedir) # flags CPPFLAGS += -D_BSD_SOURCE -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} ${INIFLAGS} diff --git a/dunst.c b/dunst.c index 44f011d..530e489 100644 --- a/dunst.c +++ b/dunst.c @@ -9,6 +9,8 @@ #include #include #include +#include +#include #include #include #include @@ -474,13 +476,22 @@ char *draw_txt_get_line(draw_txt * dt, int line) int calculate_x_offset(int line_width, int text_width) { + int leftover = line_width - text_width; + struct timeval t; + float pos; + /* If the text is wider than the frame, bouncing is enabled and word_wrap disabled */ + if (line_width < text_width && bounce_freq > 0.0001 && !word_wrap) { + gettimeofday(&t, NULL); + pos = ((t.tv_sec % 100) * 1e6 + t.tv_usec) / (1e6 / bounce_freq); + return (1 + sinf(2 * 3.14159 * pos)) * leftover / 2; + } switch (align) { case left: return 0; case center: - return (line_width - text_width) / 2; + return leftover / 2; case right: - return line_width - text_width; + return leftover; default: /* this can't happen */ return 0; @@ -1552,6 +1563,8 @@ dunst_ini_handle(void *user_data, const char *section, close_all_ks.str = dunst_ini_get_string(value); } else if (strcmp(name, "history_key") == 0) { history_ks.str = dunst_ini_get_string(value); + } else if (strcmp(name, "bounce_freq") == 0) { + bounce_freq = atof(value); } else if (strcmp(name, "alignment") == 0) { if (strcmp(value, "left") == 0) align = left; diff --git a/dunstrc b/dunstrc index ea9a89f..afbbac8 100644 --- a/dunstrc +++ b/dunstrc @@ -19,6 +19,9 @@ # Possible values are "left", "center" and "right" alignment = left + # determines the bounce frequency (in hz, 0 to disable) + bounce_freq = 0 + # show age of message if message is older than show_age_threshold seconds. # set to -1 to disable show_age_threshold = 60;