diff --git a/config.mk b/config.mk index af23c7c..63e0393 100644 --- a/config.mk +++ b/config.mk @@ -11,7 +11,7 @@ XINERAMAFLAGS = -DXINERAMA # includes and libs INCS = -I${X11INC} -I/usr/lib/dbus-1.0/include -I/usr/include/dbus-1.0 -LIBS = -L${X11LIB} -lX11 -ldbus-1 -lpthread -lrt -liniparser ${XINERAMALIBS} +LIBS = -L${X11LIB} -lX11 -lXext -lXss -ldbus-1 -lpthread -lrt -liniparser ${XINERAMALIBS} # flags CPPFLAGS = -D_BSD_SOURCE -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} diff --git a/dunst.c b/dunst.c index 83bed4b..0d6d3f5 100644 --- a/dunst.c +++ b/dunst.c @@ -13,6 +13,7 @@ #ifdef XINERAMA #include #endif +#include #include @@ -52,6 +53,7 @@ int sort = True; /* sort messages by urgency */ int indicate_hidden = True; /* show count of hidden messages */ char *key_string = NULL; KeySym mask = 0; +int idle_threshold = 0; int verbosity = 0; @@ -68,6 +70,7 @@ static int visible = False; static KeySym key = NoSymbol; static screen_info scr; static dimension_t geometry; +static XScreenSaverInfo *screensaver_info; static int font_h; static char *config_file; @@ -90,6 +93,7 @@ void handle_mouse_click(XEvent ev); void handleXEvents(void); void initmsg(msg_queue_t *msg); rule_t *initrule(void); +int is_idle(void); char *string_replace(const char *needle, const char *replacement, char *haystack); void run(void); void setup(void); @@ -232,6 +236,11 @@ check_timeouts(void) { cur = msgqueue; while(cur != NULL) { + if(is_idle()) { + cur->start = now; + cur = cur->next; + continue; + } if(cur->start == 0 || cur->timeout == 0) { cur = cur->next; continue; @@ -554,6 +563,17 @@ initrule(void) { return r; } +int +is_idle(void) +{ + XScreenSaverQueryInfo(dc->dpy, DefaultRootWindow(dc->dpy), + screensaver_info); + if(idle_threshold == 0) { + return False; + } + return screensaver_info->idle / 1000 > idle_threshold; +} + char * string_replace(const char *needle, const char *replacement, char *haystack) { char *tmp, *start; @@ -980,6 +1000,7 @@ main(int argc, char *argv[]) { parse_dunstrc(); parse_cmdline(argc, argv); key = key_string ? XStringToKeysym(key_string) : NoSymbol; + screensaver_info = XScreenSaverAllocInfo(); initdbus(); initfont(dc, font);