Index: Core/Util.cpp =================================================================== --- Core/Util.cpp (wersja 7991) +++ Core/Util.cpp (kopia robocza) @@ -785,14 +785,53 @@ String CurrentSoundTheme = "freedesktop"; +// Copy from PrinterJob.cpp -> I think it should be part of POSIX U++ library!!! +static String System(const char *cmd, const String& in) +{ + String ofn = GetTempFileName(); + String ifn = GetTempFileName(); + SaveFile(ifn, in); + String c = cmd; + c << " >" << ofn; + if(in.GetCount()) + c << " <" << ifn; + String q; + if(system(c) >= 0) + q = LoadFile(ofn); + FileDelete(ofn); + FileDelete(ifn); + return q; +} + +static String FindPlayer() +{ + static String player; + + if (player.IsEmpty()) { + const char *players[] = { "play", "ogg123" }; + + for (int i = 0; i < __countof(players); i++) { + if (!System("which " + String(players[i]), Null).IsEmpty()) { + player = players[i]; + break; + } + } + } + + return player; +} + static void LinuxBeep(const char *name) { - String fn = "/usr/share/sounds/" + CurrentSoundTheme + "/stereo/dialog-" + name; - system("play -q " + fn + (FileExists(fn + ".ogg") ? ".ogg" : - FileExists(fn + ".oga") ? ".oga" : - FileExists(fn + ".wav") ? ".wav" : - ".*") - + " >/dev/null 2>/dev/null&"); + String player = FindPlayer(); + if (!player.IsEmpty()) { + String fn = "/usr/share/sounds/" + CurrentSoundTheme + "/stereo/dialog-" + name; + system(player + " -q " + fn + (FileExists(fn + ".ogg") ? ".ogg" : + FileExists(fn + ".oga") ? ".oga" : + FileExists(fn + ".wav") ? ".wav" : + ".*") + + " >/dev/null 2>/dev/null&"); + } } #endif