posted on June 6, 2009
I compiled KDE on my gentoo install with -arts USE flag. So I needed an alternative for playing the KDE sound notifications. So I wrote a program in C to launch the appropriate player for each type of audio file, in a forked process.
#include <unistd.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv)
{
if (argc != 2) {
("Exactly one argument expected.\n");
printfreturn 0;
}
char *ext = strrchr(argv[1], '.');
++;
extif (ext == NULL) {
return 1;
}
if (fork() == 0) {
if (strcmp(ext, "wav") == 0)
("/usr/bin/aplay", "/usr/bin/aplay", "-q", argv[1], NULL);
execlelse if (strcmp(ext, "ogg") == 0)
("/usr/bin/ogg123", "/usr/bin/ogg123", "-q", argv[1], NULL);
execlelse if (strcmp(ext, "mp3") == 0)
("/usr/bin/mpg123", "/usr/bin/mpg123", "-q", argv[1], NULL);
execlelse
("/usr/bin/mplayer", "/usr/bin/mplayer", "-vo", "null", "-really-quiet", argv[1], NULL);
execl}
return 0;
}
References: http://www.gentoo-wiki.info/TIP_Audio_notifications_in_KDE_3_without_aRts (Actually there is a mistake in the program on the gentoo wiki which I corrected)