diff --git a/dunst.c b/dunst.c index c695002..74c3fcc 100644 --- a/dunst.c +++ b/dunst.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -271,6 +272,22 @@ gboolean run(void *data) return false; } +gboolean pause_signal (gpointer data) +{ + pause_display = true; + wake_up(); + + return G_SOURCE_CONTINUE; +} + +gboolean unpause_signal (gpointer data) +{ + pause_display = false; + wake_up(); + + return G_SOURCE_CONTINUE; +} + int main(int argc, char *argv[]) { @@ -300,9 +317,6 @@ int main(int argc, char *argv[]) x_setup(); - signal(SIGUSR1, pause_signal_handler); - signal(SIGUSR2, pause_signal_handler); - if (settings.startup_notification) { notification *n = malloc(sizeof(notification)); n->appname = strdup("dunst"); @@ -345,6 +359,9 @@ int main(int argc, char *argv[]) g_source_attach(x11_source, NULL); + g_unix_signal_add(SIGUSR1, pause_signal, NULL); + g_unix_signal_add(SIGUSR2, unpause_signal, NULL); + run(NULL); g_main_loop_run(mainloop); @@ -353,20 +370,6 @@ int main(int argc, char *argv[]) return 0; } -void pause_signal_handler(int sig) -{ - if (sig == SIGUSR1) { - pause_display = true; - wake_up(); - } - if (sig == SIGUSR2) { - pause_display = false; - wake_up(); - } - - signal(sig, pause_signal_handler); -} - void usage(int exit_status) { fputs("usage:\n", stderr);