Background Process Launching XOJO App has no Sound.

Need the help of some Linux Gurus - Ok let’s say that I write a desktop app for Linux and all it does when when you launch it…is bring up a UI play a sound and then quit.
The app works beautifully. You launch… it opens…it plays…it closes. Awesome. Then I created a Cron Job / background process….that launches that program at some specific time or interval. Whenever the application launches…. it doesn’t play any sound. It behaves as if it’s playing. You get no error messages… but you get no sound :frowning:

That seems to be because the background process is running as root or some other user. I created a processes that monitors my UPS in the background. If the UPS loses power…. it can “launch any program” – I want it to launch my XOJO “ALARM” program that simply plays a sound. I know the ALARM program works because it played perfectly when I launch it. I know the script is launching it…because the UI appears…. but it can’t seem to play any sound.

I tried updating sudoers so that the application would always launch “as me” – which i expected would work. Alas…no luck. I just can’t get a background process to play any sound no matter what it runs.

Have any ideas?

Well a cron job may not have any terminal & other user environment attached to it
It could run when there’s no user logged in
And THAT makes all the difference in the world

And actually…that’s more or less the idea. This Linux system is a monitor attached to an UPS and the Network. When the UPS loses power…… if the power isn’t restored in 60 seconds…. it starts running and tracking/logging shell commands to start suspending our virtual machines and performs an ssh shutdown on dozens of other systems….and it all works pretty well. If my building loses power this one system waits a little bit and then runs commands to shutdown dozens of other servers (like 70 ~ 80+). However…if some uninformed person accidentally unplugs this particular UPS…… I want the system to sound an ALERT immediately . You get 60 seconds to get that system back on power before all hell breaks loose. lol. I have the engine for all of this working…but for some reason it seems a program launched from a background task can’t make any sound. And there’s no error. I behaves just as if it’s doing it. If the sound is 17 seconds long…then the app waits exactly 17 seconds before building a small log file etc. The program “thinks” that sound is playing. I’m actually just running the shell program “aplay” – but I’ve had the same issue with XOJO’s I was hopping that if I could figure out why XOJO doesn’t create sound when launched from a background process….perhaps that will help pinpoint the problem in general.

The system usually has a user logged on…but it may be at the lock screen. The environment issue is definitely something I’ll look into. I didn’t expect it would be quite so tough to somehow just write a program that for example plays a .WAV file every 10 minutes whether or not a user is logged on.