diff --git a/config.def.h b/config.def.h index 86b7e76..62a158f 100644 --- a/config.def.h +++ b/config.def.h @@ -15,5 +15,7 @@ enum corners corner = TOP_RIGHT; static const unsigned int duration = 5; /* in seconds */ +static const char *soundcmd[] = { NULL }; /* NULL for no sound */ + #define DISMISS_BUTTON Button1 #define ACTION_BUTTON Button3 diff --git a/herbe.c b/herbe.c index 51d3990..06f07e3 100644 --- a/herbe.c +++ b/herbe.c @@ -79,6 +79,18 @@ void expire(int sig) XFlush(display); } +static void playsound(void) +{ + if (soundcmd[0] == NULL) return; + + /* Forking to avoid delay */ + if (fork() == 0) { + setsid(); + execvp(soundcmd[0], (char *const *)soundcmd); + _exit(1); + } +} + int main(int argc, char *argv[]) { if (argc == 1) @@ -171,6 +183,8 @@ int main(int argc, char *argv[]) XSelectInput(display, window, ExposureMask | ButtonPress); XMapWindow(display, window); + playsound(); + sem_t *mutex = sem_open("/herbe", O_CREAT, 0644, 1); sem_wait(mutex); @@ -217,4 +231,4 @@ int main(int argc, char *argv[]) XCloseDisplay(display); return exit_code; -} \ No newline at end of file +}