From a378aa9b196f5f73fcfcc278c72fa40b2ee0d6aa Mon Sep 17 00:00:00 2001 From: Sascha Kruse Date: Sat, 8 Dec 2012 15:42:44 +0100 Subject: [PATCH] pause/unpause via SIGUSR1/SIGUSR2 --- README.pod | 9 ++++++++- dunst.c | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/README.pod b/README.pod index 36e7cbd..10a9662 100644 --- a/README.pod +++ b/README.pod @@ -148,7 +148,14 @@ The progress value can be set with a hint, too. =head1 MISCELLANEOUS Dunst can be paused by sending a notification with a summary of "DUNST_COMMAND_PAUSE" -and resumed with a summary of "DUNST_COMMAND_RESUME". +and resumed with a summary of "DUNST_COMMAND_RESUME". Alternatively you can send SIGUSR1 and SIGUSR2 to pause and unpause respectivly. For Example: + +=item killall -SIGUSR1 dunst # pause + +=item killall -SIGUSR2 dunst # resume + +=back + When paused dunst will not display any notifications but keep all notifications in a queue. This can for example be wrapped around a screen locker (i3lock, slock) to prevent flickering of notifications through the lock and to read all missed notifications after returning to the computer. diff --git a/dunst.c b/dunst.c index af91632..abd63e4 100644 --- a/dunst.c +++ b/dunst.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -108,6 +109,18 @@ void warn(const char *text, int urg); void init_shortcut(keyboard_shortcut * shortcut); KeySym string_to_mask(char *str); +void pause_signal_handler(int sig) +{ + if (sig == SIGUSR1) { + pause_display = true; + } + if (sig == SIGUSR2) { + pause_display = false; + } + + signal (sig, pause_signal_handler); +} + static void print_notification(notification * n) { printf("{\n"); @@ -1714,6 +1727,8 @@ int main(int argc, char *argv[]) initdbus(); setup(); + signal (SIGUSR1, pause_signal_handler); + signal (SIGUSR2, pause_signal_handler); if (deprecated_mod) warn("-mod is deprecated. Use \"-key mod+key\" instead\n",